diff --git a/README.md b/README.md index be1f8e546..2f0c390ee 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,8 @@ dependencies { ### Compatibility Matrix Appium Java Client | Selenium client ----------------------------------------------------------------------------------------------------|----------------------------- -`9.4.0` | `4.26.0`, `4.27.0`, `4.28.0` +- | `4.34.0` +`9.4.0` | `4.26.0`, `4.27.0`, `4.28.0`, `4.28.1`, `4.29.0`, `4.30.0`, `4.31.0`, `4.32.0`, `4.33.0` `9.2.1`(known issues: appium/java-client#2145, appium/java-client#2146), `9.2.2`, `9.2.3`, `9.3.0` | `4.19.0`, `4.19.1`, `4.20.0`, `4.21.0`, `4.22.0`, `4.23.0`, `4.23.1`, `4.24.0`, `4.25.0`, `4.26.0`, `4.27.0` `9.1.0`, `9.2.0` | `4.17.0`, `4.18.0`, `4.18.1` `9.0.0` | `4.14.1`, `4.15.0`, `4.16.0` (partially [corrupted](https://github.com/SeleniumHQ/selenium/issues/13256)), `4.16.1` diff --git a/src/main/java/io/appium/java_client/HasBrowserCheck.java b/src/main/java/io/appium/java_client/HasBrowserCheck.java index ebce4a3c5..eea25072e 100644 --- a/src/main/java/io/appium/java_client/HasBrowserCheck.java +++ b/src/main/java/io/appium/java_client/HasBrowserCheck.java @@ -1,7 +1,7 @@ package io.appium.java_client; import io.appium.java_client.internal.CapabilityHelpers; -import org.openqa.selenium.ContextAware; +import io.appium.java_client.remote.SupportsContextSwitching; import org.openqa.selenium.HasCapabilities; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.CapabilityType; @@ -29,11 +29,11 @@ default boolean isBrowser() { // ignore } } - if (!(this instanceof ContextAware)) { + if (!(this instanceof SupportsContextSwitching)) { return false; } try { - var context = ((ContextAware) this).getContext(); + var context = ((SupportsContextSwitching) this).getContext(); return context != null && !context.toUpperCase().contains(NATIVE_CONTEXT); } catch (WebDriverException e) { return false; diff --git a/src/main/java/io/appium/java_client/pagefactory/utils/WebDriverUnpackUtility.java b/src/main/java/io/appium/java_client/pagefactory/utils/WebDriverUnpackUtility.java index 997460be5..8afc2d9cf 100644 --- a/src/main/java/io/appium/java_client/pagefactory/utils/WebDriverUnpackUtility.java +++ b/src/main/java/io/appium/java_client/pagefactory/utils/WebDriverUnpackUtility.java @@ -18,8 +18,8 @@ import io.appium.java_client.HasBrowserCheck; import io.appium.java_client.pagefactory.bys.ContentType; +import io.appium.java_client.remote.SupportsContextSwitching; import org.jspecify.annotations.Nullable; -import org.openqa.selenium.ContextAware; import org.openqa.selenium.SearchContext; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WrapsDriver; @@ -92,12 +92,13 @@ public static WebDriver unpackWebDriverFromSearchContext(@Nullable SearchContext * {@link WebDriver} or {@link org.openqa.selenium.WebElement} or some other * user's extension/implementation. * Note: if you want to use your own implementation then it should - * implement {@link ContextAware} or {@link WrapsDriver} or {@link HasBrowserCheck} + * implement {@link SupportsContextSwitching} or {@link WrapsDriver} or {@link HasBrowserCheck} * @return current content type. It depends on current context. If current context is * NATIVE_APP it will return {@link ContentType#NATIVE_MOBILE_SPECIFIC}. * {@link ContentType#HTML_OR_DEFAULT} will be returned if the current context is WEB_VIEW. * {@link ContentType#HTML_OR_DEFAULT} also will be returned if the given - * {@link SearchContext} instance doesn't implement {@link ContextAware} and {@link WrapsDriver} + * {@link SearchContext} instance doesn't implement {@link SupportsContextSwitching} and + * {@link WrapsDriver} */ public static ContentType getCurrentContentType(SearchContext context) { var browserCheckHolder = unpackObjectFromSearchContext(context, HasBrowserCheck.class); @@ -105,8 +106,8 @@ public static ContentType getCurrentContentType(SearchContext context) { return NATIVE_MOBILE_SPECIFIC; } - var contextAware = unpackObjectFromSearchContext(context, ContextAware.class); - if (contextAware.map(ContextAware::getContext) + var contextAware = unpackObjectFromSearchContext(context, SupportsContextSwitching.class); + if (contextAware.map(SupportsContextSwitching::getContext) .filter(c -> c.toUpperCase().contains(NATIVE_CONTEXT)).isPresent()) { return NATIVE_MOBILE_SPECIFIC; } diff --git a/src/main/java/io/appium/java_client/remote/SupportsContextSwitching.java b/src/main/java/io/appium/java_client/remote/SupportsContextSwitching.java index 7fad6f0e5..c576583dc 100644 --- a/src/main/java/io/appium/java_client/remote/SupportsContextSwitching.java +++ b/src/main/java/io/appium/java_client/remote/SupportsContextSwitching.java @@ -20,7 +20,6 @@ import io.appium.java_client.MobileCommand; import io.appium.java_client.NoSuchContextException; import org.jspecify.annotations.Nullable; -import org.openqa.selenium.ContextAware; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.remote.Response; @@ -32,7 +31,7 @@ import static java.util.Objects.requireNonNull; -public interface SupportsContextSwitching extends WebDriver, ContextAware, ExecutesMethod { +public interface SupportsContextSwitching extends WebDriver, ExecutesMethod { /** * Switches to the given context. * diff --git a/src/test/java/io/appium/java_client/events/stubs/EmptyWebDriver.java b/src/test/java/io/appium/java_client/events/stubs/EmptyWebDriver.java index c07df5b68..f4d4aab96 100644 --- a/src/test/java/io/appium/java_client/events/stubs/EmptyWebDriver.java +++ b/src/test/java/io/appium/java_client/events/stubs/EmptyWebDriver.java @@ -19,7 +19,6 @@ import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.Capabilities; -import org.openqa.selenium.ContextAware; import org.openqa.selenium.Cookie; import org.openqa.selenium.HasCapabilities; import org.openqa.selenium.JavascriptExecutor; @@ -39,8 +38,7 @@ import java.util.Map; import java.util.Set; -public class EmptyWebDriver implements WebDriver, ContextAware, - JavascriptExecutor, HasCapabilities, TakesScreenshot { +public class EmptyWebDriver implements WebDriver, JavascriptExecutor, HasCapabilities, TakesScreenshot { public EmptyWebDriver() { } @@ -48,18 +46,6 @@ private static List createStubList() { return List.of(new StubWebElement(), new StubWebElement()); } - public WebDriver context(String name) { - return null; - } - - public Set getContextHandles() { - return null; - } - - public String getContext() { - return ""; - } - public void get(String url) { }