Skip to content

Commit d01161d

Browse files
feat: Implement HasBiDi interface support in AppiumDriver (#2250)
1 parent 7fc702e commit d01161d

File tree

15 files changed

+296
-98
lines changed

15 files changed

+296
-98
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ concurrency:
1919
cancel-in-progress: true
2020

2121
env:
22+
CI: true
2223
ANDROID_SDK_VERSION: "28"
2324
ANDROID_EMU_NAME: test
2425
ANDROID_EMU_TARGET: default

src/e2eAndroidTest/java/io/appium/java_client/android/AndroidContextTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.junit.jupiter.api.BeforeAll;
2121
import org.junit.jupiter.api.Test;
2222

23+
import static io.appium.java_client.HasBrowserCheck.NATIVE_CONTEXT;
2324
import static org.junit.jupiter.api.Assertions.assertEquals;
2425
import static org.junit.jupiter.api.Assertions.assertThrows;
2526

@@ -31,7 +32,7 @@ public class AndroidContextTest extends BaseAndroidTest {
3132
}
3233

3334
@Test public void testGetContext() {
34-
assertEquals("NATIVE_APP", driver.getContext());
35+
assertEquals(NATIVE_CONTEXT, driver.getContext());
3536
}
3637

3738
@Test public void testGetContextHandles() {
@@ -42,8 +43,8 @@ public class AndroidContextTest extends BaseAndroidTest {
4243
driver.getContextHandles();
4344
driver.context("WEBVIEW_io.appium.android.apis");
4445
assertEquals(driver.getContext(), "WEBVIEW_io.appium.android.apis");
45-
driver.context("NATIVE_APP");
46-
assertEquals(driver.getContext(), "NATIVE_APP");
46+
driver.context(NATIVE_CONTEXT);
47+
assertEquals(driver.getContext(), NATIVE_CONTEXT);
4748
}
4849

4950
@Test public void testContextError() {

src/e2eAndroidTest/java/io/appium/java_client/android/AndroidFunctionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.regex.Matcher;
1919
import java.util.regex.Pattern;
2020

21+
import static io.appium.java_client.HasBrowserCheck.NATIVE_CONTEXT;
2122
import static java.time.Duration.ofMillis;
2223
import static java.time.Duration.ofSeconds;
2324
import static org.hamcrest.MatcherAssert.assertThat;
@@ -75,7 +76,7 @@ public static void startWebViewActivity() {
7576
@BeforeEach
7677
public void setUp() {
7778

78-
driver.context("NATIVE_APP");
79+
driver.context(NATIVE_CONTEXT);
7980
}
8081

8182
@Test

src/e2eIosTest/java/io/appium/java_client/ios/AppIOSTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static void beforeClass() {
2121
.setDeviceName(DEVICE_NAME)
2222
.setCommandTimeouts(Duration.ofSeconds(240))
2323
.setApp(TEST_APP_ZIP)
24+
.enableBiDi()
2425
.setWdaLaunchTimeout(WDA_LAUNCH_TIMEOUT);
2526
try {
2627
driver = new IOSDriver(service.getUrl(), options);

src/e2eIosTest/java/io/appium/java_client/ios/BaseIOSWebViewTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public static void beforeClass() {
3939
.setDeviceName(DEVICE_NAME)
4040
.setWdaLaunchTimeout(WDA_LAUNCH_TIMEOUT)
4141
.setCommandTimeouts(Duration.ofSeconds(240))
42-
.setShowIosLog(true)
4342
.setApp(VODQA_ZIP);
4443
Supplier<IOSDriver> createDriver = () -> new IOSDriver(service.getUrl(), options);
4544
try {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios;
18+
19+
import org.junit.jupiter.api.Disabled;
20+
import org.junit.jupiter.api.Test;
21+
import org.openqa.selenium.bidi.log.LogEntry;
22+
import org.openqa.selenium.bidi.module.LogInspector;
23+
24+
import java.util.concurrent.CopyOnWriteArrayList;
25+
26+
import static io.appium.java_client.HasBrowserCheck.NATIVE_CONTEXT;
27+
import static org.junit.jupiter.api.Assertions.assertFalse;
28+
29+
public class IOSBiDiTest extends AppIOSTest {
30+
31+
@Test
32+
@Disabled("Need to resolve compatibility issues")
33+
public void listenForIosLogs() {
34+
var logs = new CopyOnWriteArrayList<LogEntry>();
35+
try (var logInspector = new LogInspector(NATIVE_CONTEXT, driver)) {
36+
logInspector.onLog(logs::add);
37+
driver.getPageSource();
38+
}
39+
assertFalse(logs.isEmpty());
40+
}
41+
42+
}

src/e2eIosTest/java/io/appium/java_client/ios/IOSContextTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.appium.java_client.NoSuchContextException;
2020
import org.junit.jupiter.api.Test;
2121

22+
import static io.appium.java_client.HasBrowserCheck.NATIVE_CONTEXT;
2223
import static org.hamcrest.MatcherAssert.assertThat;
2324
import static org.hamcrest.core.StringContains.containsString;
2425
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -27,7 +28,7 @@
2728
public class IOSContextTest extends BaseIOSWebViewTest {
2829

2930
@Test public void testGetContext() {
30-
assertEquals("NATIVE_APP", driver.getContext());
31+
assertEquals(NATIVE_CONTEXT, driver.getContext());
3132
}
3233

3334
@Test public void testGetContextHandles() {
@@ -38,7 +39,7 @@ public class IOSContextTest extends BaseIOSWebViewTest {
3839
driver.getContextHandles();
3940
findAndSwitchToWebView();
4041
assertThat(driver.getContext(), containsString("WEBVIEW"));
41-
driver.context("NATIVE_APP");
42+
driver.context(NATIVE_CONTEXT);
4243
}
4344

4445
@Test public void testContextError() {

src/e2eIosTest/java/io/appium/java_client/ios/IOSWebViewTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.appium.java_client.ios;
22

33
import io.appium.java_client.AppiumBy;
4+
import io.appium.java_client.TestUtils;
5+
import org.junit.jupiter.api.Assumptions;
46
import org.junit.jupiter.api.Test;
57
import org.openqa.selenium.By;
68
import org.openqa.selenium.support.ui.ExpectedConditions;
@@ -15,6 +17,9 @@ public class IOSWebViewTest extends BaseIOSWebViewTest {
1517

1618
@Test
1719
public void webViewPageTestCase() throws InterruptedException {
20+
// this test is not stable in the CI env
21+
Assumptions.assumeFalse(TestUtils.isCiEnv());
22+
1823
new WebDriverWait(driver, LOOKUP_TIMEOUT)
1924
.until(ExpectedConditions.presenceOfElementLocated(By.id("login")))
2025
.click();

0 commit comments

Comments
 (0)