Skip to content

Commit 3739995

Browse files
committed
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
1 parent 1abd110 commit 3739995

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

gradle.properties

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

3-
selenium.version=4.40.0
3+
#selenium.version=4.40.0
4+
selenium.version=4.42.0-SNAPSHOT
45
# Please increment the value in a release
56
appiumClient.version=10.0.0

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.appium.java_client;
1818

19+
import org.jspecify.annotations.Nullable;
1920
import org.openqa.selenium.remote.ExecuteMethod;
2021
import org.openqa.selenium.remote.Response;
2122

@@ -35,7 +36,9 @@ public AppiumExecutionMethod(AppiumDriver driver) {
3536
* @param parameters is a map which contains parameter names as keys and parameter values
3637
* @return a command execution result
3738
*/
38-
public Object execute(String commandName, Map<String, ?> parameters) {
39+
@Nullable
40+
@SuppressWarnings("unchecked")
41+
public <T> T execute(String commandName, @Nullable Map<String, ?> parameters) {
3942
Response response;
4043

4144
if (parameters == null || parameters.isEmpty()) {
@@ -44,6 +47,6 @@ public Object execute(String commandName, Map<String, ?> parameters) {
4447
response = driver.execute(commandName, parameters);
4548
}
4649

47-
return response.getValue();
50+
return (T) response.getValue();
4851
}
4952
}

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

Lines changed: 10 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,15 @@ 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(Function<? super T, ? extends V> isTrue, Instant start, Instant end) {
215220
var iterationNumber = 1;
216221
Throwable lastException;
217222

@@ -245,8 +250,8 @@ private <V> V performIteration(Function<? super T, V> isTrue, Instant start, Ins
245250
}
246251
}
247252

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

0 commit comments

Comments
 (0)