Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement HasBiDi interface support in AppiumDriver #2250

Merged
merged 9 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static io.appium.java_client.HasBrowserCheck.NATIVE_CONTEXT;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand All @@ -31,7 +32,7 @@ public class AndroidContextTest extends BaseAndroidTest {
}

@Test public void testGetContext() {
assertEquals("NATIVE_APP", driver.getContext());
assertEquals(NATIVE_CONTEXT, driver.getContext());
}

@Test public void testGetContextHandles() {
Expand All @@ -42,8 +43,8 @@ public class AndroidContextTest extends BaseAndroidTest {
driver.getContextHandles();
driver.context("WEBVIEW_io.appium.android.apis");
assertEquals(driver.getContext(), "WEBVIEW_io.appium.android.apis");
driver.context("NATIVE_APP");
assertEquals(driver.getContext(), "NATIVE_APP");
driver.context(NATIVE_CONTEXT);
assertEquals(driver.getContext(), NATIVE_CONTEXT);
}

@Test public void testContextError() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static io.appium.java_client.HasBrowserCheck.NATIVE_CONTEXT;
import static java.time.Duration.ofMillis;
import static java.time.Duration.ofSeconds;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -75,7 +76,7 @@ public static void startWebViewActivity() {
@BeforeEach
public void setUp() {

driver.context("NATIVE_APP");
driver.context(NATIVE_CONTEXT);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static void beforeClass() {
.setDeviceName(DEVICE_NAME)
.setCommandTimeouts(Duration.ofSeconds(240))
.setApp(TEST_APP_ZIP)
.enableBiDi()
.setWdaLaunchTimeout(WDA_LAUNCH_TIMEOUT);
try {
driver = new IOSDriver(service.getUrl(), options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public static void beforeClass() {
.setDeviceName(DEVICE_NAME)
.setWdaLaunchTimeout(WDA_LAUNCH_TIMEOUT)
.setCommandTimeouts(Duration.ofSeconds(240))
.setShowIosLog(true)
.setApp(VODQA_ZIP);
Supplier<IOSDriver> createDriver = () -> new IOSDriver(service.getUrl(), options);
try {
Expand Down
42 changes: 42 additions & 0 deletions src/e2eIosTest/java/io/appium/java_client/ios/IOSBiDiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.appium.java_client.ios;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.bidi.log.LogEntry;
import org.openqa.selenium.bidi.module.LogInspector;

import java.util.concurrent.CopyOnWriteArrayList;

import static io.appium.java_client.HasBrowserCheck.NATIVE_CONTEXT;
import static org.junit.jupiter.api.Assertions.assertFalse;

public class IOSBiDiTest extends AppIOSTest {

@Test
@Disabled("Need to resolve compatibility issues")
public void listenForIosLogs() {
var logs = new CopyOnWriteArrayList<LogEntry>();
try (var logInspector = new LogInspector(NATIVE_CONTEXT, driver)) {
logInspector.onLog(logs::add);
driver.getPageSource();
}
assertFalse(logs.isEmpty());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.appium.java_client.NoSuchContextException;
import org.junit.jupiter.api.Test;

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

@Test public void testGetContext() {
assertEquals("NATIVE_APP", driver.getContext());
assertEquals(NATIVE_CONTEXT, driver.getContext());
}

@Test public void testGetContextHandles() {
Expand All @@ -38,7 +39,7 @@ public class IOSContextTest extends BaseIOSWebViewTest {
driver.getContextHandles();
findAndSwitchToWebView();
assertThat(driver.getContext(), containsString("WEBVIEW"));
driver.context("NATIVE_APP");
driver.context(NATIVE_CONTEXT);
}

@Test public void testContextError() {
Expand Down
Loading
Loading