
net.serenitybdd.screenplay.waits.WaitOnSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of serenity-screenplay Show documentation
Show all versions of serenity-screenplay Show documentation
Support for the User Journey pattern in Serenity
package net.serenitybdd.screenplay.waits;
import net.serenitybdd.screenplay.Actor;
import net.thucydides.model.environment.SystemEnvironmentVariables;
import org.awaitility.Awaitility;
import java.time.Duration;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import static net.thucydides.model.ThucydidesSystemProperty.WEBDRIVER_WAIT_FOR_TIMEOUT;
public class WaitOnSupplier extends WaitWithTimeout {
private final Callable expectedState;
public WaitOnSupplier(Callable expectedState) {
this.expectedState = expectedState;
int durationInMillis = SystemEnvironmentVariables.currentEnvironmentVariables().getPropertyAsInteger(WEBDRIVER_WAIT_FOR_TIMEOUT, 3000);
this.timeout = Duration.ofMillis(durationInMillis);
}
@Override
public void performAs(T actor) {
Awaitility.await().pollInSameThread().atMost(timeout.toMillis(), TimeUnit.MILLISECONDS).until(expectedState);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy