Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

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;

Expand All @@ -35,7 +37,8 @@ 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<String, ?> parameters) {
@Nullable
public Object execute(@NonNull String commandName, @Nullable Map<String, ?> parameters) {
Response response;

if (parameters == null || parameters.isEmpty()) {
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/io/appium/java_client/AppiumFluentWait.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +35,9 @@
import java.util.function.Function;
import java.util.function.Supplier;

@NullMarked
public class AppiumFluentWait<T> extends FluentWait<T> {
@Nullable
private Function<IterationInfo, Duration> pollingStrategy = null;

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

protected Supplier<String> getMessageSupplier() {
protected Supplier<@Nullable String> getMessageSupplier() {
return messageSupplier;
}

Expand Down Expand Up @@ -203,15 +208,15 @@ public AppiumFluentWait<T> withPollingStrategy(Function<IterationInfo, Duration>
* @throws TimeoutException If the timeout expires.
*/
@Override
public <V> V until(Function<? super T, V> isTrue) {
public <V extends @Nullable Object> @NonNull V until(Function<? super T, ? extends V> 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);

return performIteration(isTrue, start, end);
}

private <V> V performIteration(Function<? super T, V> isTrue, Instant start, Instant end) {
private <V extends @Nullable Object> @NonNull V performIteration(Function<? super T, ? extends V> isTrue, Instant start, Instant end) {
var iterationNumber = 1;
Throwable lastException;

Expand Down Expand Up @@ -245,8 +250,8 @@ private <V> V performIteration(Function<? super T, V> isTrue, Instant start, Ins
}
}

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

Expand Down
Loading