From 8ca37c636fe0f1429c4ef031fc76d464f585f6e9 Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Thu, 5 Mar 2026 10:27:08 +0200 Subject: [PATCH 1/2] fix: make API changes compatible with Selenium 4.24.0-SNAPSHOT Unfortunately, these two public methods have been changed in Selenium 4.24.0-SNAPSHOT: * org.openqa.selenium.remote.ExecuteMethod#execute * org.openqa.selenium.support.ui.FluentWait#until --- gradle.properties | 3 ++- .../appium/java_client/AppiumExecutionMethod.java | 7 +++++-- .../io/appium/java_client/AppiumFluentWait.java | 15 ++++++++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1540f2707..5f91568e8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ org.gradle.daemon=true -selenium.version=4.40.0 +#selenium.version=4.40.0 +selenium.version=4.42.0-SNAPSHOT # Please increment the value in a release appiumClient.version=10.0.0 diff --git a/src/main/java/io/appium/java_client/AppiumExecutionMethod.java b/src/main/java/io/appium/java_client/AppiumExecutionMethod.java index 34a848f79..3b2816ce6 100644 --- a/src/main/java/io/appium/java_client/AppiumExecutionMethod.java +++ b/src/main/java/io/appium/java_client/AppiumExecutionMethod.java @@ -16,6 +16,7 @@ package io.appium.java_client; +import org.jspecify.annotations.Nullable; import org.openqa.selenium.remote.ExecuteMethod; import org.openqa.selenium.remote.Response; @@ -35,7 +36,9 @@ public AppiumExecutionMethod(AppiumDriver driver) { * @param parameters is a map which contains parameter names as keys and parameter values * @return a command execution result */ - public Object execute(String commandName, Map parameters) { + @Nullable + @SuppressWarnings("unchecked") + public T execute(String commandName, @Nullable Map parameters) { Response response; if (parameters == null || parameters.isEmpty()) { @@ -44,6 +47,6 @@ public Object execute(String commandName, Map parameters) { response = driver.execute(commandName, parameters); } - return response.getValue(); + return (T) response.getValue(); } } diff --git a/src/main/java/io/appium/java_client/AppiumFluentWait.java b/src/main/java/io/appium/java_client/AppiumFluentWait.java index a284e1ebb..035a5db1b 100644 --- a/src/main/java/io/appium/java_client/AppiumFluentWait.java +++ b/src/main/java/io/appium/java_client/AppiumFluentWait.java @@ -19,6 +19,9 @@ import com.google.common.base.Throwables; import lombok.AccessLevel; import lombok.Getter; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.support.ui.FluentWait; @@ -32,7 +35,9 @@ import java.util.function.Function; import java.util.function.Supplier; +@NullMarked public class AppiumFluentWait extends FluentWait { + @Nullable private Function pollingStrategy = null; private static final Duration DEFAULT_POLL_DELAY_DURATION = Duration.ZERO; @@ -133,7 +138,7 @@ protected List> getIgnoredExceptions() { return ignoredExceptions; } - protected Supplier getMessageSupplier() { + protected Supplier<@Nullable String> getMessageSupplier() { return messageSupplier; } @@ -203,7 +208,7 @@ public AppiumFluentWait withPollingStrategy(Function * @throws TimeoutException If the timeout expires. */ @Override - public V until(Function isTrue) { + public @NonNull V until(Function isTrue) { final var start = getClock().instant(); // Adding pollDelay to end instant will allow to verify the condition for the expected timeout duration. final var end = start.plus(getTimeout()).plus(pollDelay); @@ -211,7 +216,7 @@ public V until(Function isTrue) { return performIteration(isTrue, start, end); } - private V performIteration(Function isTrue, Instant start, Instant end) { + private @NonNull V performIteration(Function isTrue, Instant start, Instant end) { var iterationNumber = 1; Throwable lastException; @@ -245,8 +250,8 @@ private V performIteration(Function isTrue, Instant start, Ins } } - private void handleTimeoutException(Throwable lastException, Function isTrue) { - var message = Optional.ofNullable(getMessageSupplier()) + private void handleTimeoutException(@Nullable Throwable lastException, Function isTrue) { + var message = Optional.of(getMessageSupplier()) .map(Supplier::get) .orElseGet(() -> "waiting for " + isTrue); From 8b63a3a3667a788c28f65a1d21f610e8c26c3b2b Mon Sep 17 00:00:00 2001 From: Andrei Solntsev Date: Fri, 6 Mar 2026 11:29:36 +0200 Subject: [PATCH 2/2] fix: revert API change in AppiumExecutionMethod I've restored the original signature of `ExecuteMethod` in Selenium 4.24.0-SNAPSHOT (will come with next nightly build). --- .../java/io/appium/java_client/AppiumExecutionMethod.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/appium/java_client/AppiumExecutionMethod.java b/src/main/java/io/appium/java_client/AppiumExecutionMethod.java index 3b2816ce6..a77056894 100644 --- a/src/main/java/io/appium/java_client/AppiumExecutionMethod.java +++ b/src/main/java/io/appium/java_client/AppiumExecutionMethod.java @@ -16,6 +16,7 @@ package io.appium.java_client; +import org.jspecify.annotations.NonNull; import org.jspecify.annotations.Nullable; import org.openqa.selenium.remote.ExecuteMethod; import org.openqa.selenium.remote.Response; @@ -37,8 +38,7 @@ public AppiumExecutionMethod(AppiumDriver driver) { * @return a command execution result */ @Nullable - @SuppressWarnings("unchecked") - public T execute(String commandName, @Nullable Map parameters) { + public Object execute(@NonNull String commandName, @Nullable Map parameters) { Response response; if (parameters == null || parameters.isEmpty()) { @@ -47,6 +47,6 @@ public T execute(String commandName, @Nullable Map parameters) { response = driver.execute(commandName, parameters); } - return (T) response.getValue(); + return response.getValue(); } }