Skip to content

Commit 6b7597f

Browse files
authored
chore: make API changes compatible with Selenium 4.42.0 (#2390)
Unfortunately, these two public methods have been changed in Selenium 4.42.0: * org.openqa.selenium.remote.ExecuteMethod#execute * org.openqa.selenium.support.ui.FluentWait#until
1 parent 40f0341 commit 6b7597f

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ repositories {
4040
}
4141
}
4242

43+
configurations.configureEach {
44+
resolutionStrategy.cacheChangingModulesFor 1, 'minutes'
45+
}
46+
4347
java {
4448
sourceCompatibility = JavaVersion.VERSION_11
4549
targetCompatibility = JavaVersion.VERSION_11

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
org.gradle.daemon=true
22

3-
selenium.version=4.40.0
3+
selenium.version=4.42.0
44
# Please increment the value in a release
55
appiumClient.version=10.1.0

src/main/java/io/appium/java_client/AppiumExecutionMethod.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.appium.java_client;
1818

19+
import org.jspecify.annotations.NonNull;
20+
import org.jspecify.annotations.Nullable;
1921
import org.openqa.selenium.remote.ExecuteMethod;
2022
import org.openqa.selenium.remote.Response;
2123

@@ -35,7 +37,8 @@ public AppiumExecutionMethod(AppiumDriver driver) {
3537
* @param parameters is a map which contains parameter names as keys and parameter values
3638
* @return a command execution result
3739
*/
38-
public Object execute(String commandName, Map<String, ?> parameters) {
40+
@Nullable
41+
public Object execute(@NonNull String commandName, @Nullable Map<String, ?> parameters) {
3942
Response response;
4043

4144
if (parameters == null || parameters.isEmpty()) {

src/main/java/io/appium/java_client/AppiumFluentWait.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import com.google.common.base.Throwables;
2020
import lombok.AccessLevel;
2121
import lombok.Getter;
22+
import org.jspecify.annotations.NonNull;
23+
import org.jspecify.annotations.NullMarked;
24+
import org.jspecify.annotations.Nullable;
2225
import org.openqa.selenium.TimeoutException;
2326
import org.openqa.selenium.WebDriverException;
2427
import org.openqa.selenium.support.ui.FluentWait;
@@ -32,7 +35,9 @@
3235
import java.util.function.Function;
3336
import java.util.function.Supplier;
3437

38+
@NullMarked
3539
public class AppiumFluentWait<T> extends FluentWait<T> {
40+
@Nullable
3641
private Function<IterationInfo, Duration> pollingStrategy = null;
3742

3843
private static final Duration DEFAULT_POLL_DELAY_DURATION = Duration.ZERO;
@@ -133,7 +138,7 @@ protected List<Class<? extends Throwable>> getIgnoredExceptions() {
133138
return ignoredExceptions;
134139
}
135140

136-
protected Supplier<String> getMessageSupplier() {
141+
protected Supplier<@Nullable String> getMessageSupplier() {
137142
return messageSupplier;
138143
}
139144

@@ -203,15 +208,16 @@ public AppiumFluentWait<T> withPollingStrategy(Function<IterationInfo, Duration>
203208
* @throws TimeoutException If the timeout expires.
204209
*/
205210
@Override
206-
public <V> V until(Function<? super T, V> isTrue) {
211+
public <V extends @Nullable Object> @NonNull V until(Function<? super T, ? extends V> isTrue) {
207212
final var start = getClock().instant();
208213
// Adding pollDelay to end instant will allow to verify the condition for the expected timeout duration.
209214
final var end = start.plus(getTimeout()).plus(pollDelay);
210215

211216
return performIteration(isTrue, start, end);
212217
}
213218

214-
private <V> V performIteration(Function<? super T, V> isTrue, Instant start, Instant end) {
219+
private <V extends @Nullable Object> @NonNull V performIteration(
220+
Function<? super T, ? extends V> isTrue, Instant start, Instant end) {
215221
var iterationNumber = 1;
216222
Throwable lastException;
217223

@@ -245,8 +251,9 @@ private <V> V performIteration(Function<? super T, V> isTrue, Instant start, Ins
245251
}
246252
}
247253

248-
private <V> void handleTimeoutException(Throwable lastException, Function<? super T, V> isTrue) {
249-
var message = Optional.ofNullable(getMessageSupplier())
254+
private <V> void handleTimeoutException(
255+
@Nullable Throwable lastException, Function<? super T, ? extends V> isTrue) {
256+
var message = Optional.of(getMessageSupplier())
250257
.map(Supplier::get)
251258
.orElseGet(() -> "waiting for " + isTrue);
252259

0 commit comments

Comments
 (0)