net.serenitybdd.core.pages.FindAllWithRetry Maven / Gradle / Ivy
package net.serenitybdd.core.pages;
import net.thucydides.model.util.EnvironmentVariables;
import org.openqa.selenium.StaleElementReferenceException;
import java.util.function.Function;
import static net.thucydides.model.ThucydidesSystemProperty.WEBDRIVER_RETRY_ON_STALE_ELEMENT_EXCEPTION;
public class FindAllWithRetry {
private final EnvironmentVariables environmentVariables;
public FindAllWithRetry(EnvironmentVariables environmentVariables) {
this.environmentVariables = environmentVariables;
}
public ListOfWebElementFacades find(Function finder, PageObject page) {
ListOfWebElementFacades matchingElements = finder.apply(page);
if (shouldRetryOnStaleElementException()) {
matchingElements.setFallback(finder, page);
}
return matchingElements;
}
private boolean shouldRetryOnStaleElementException() {
return WEBDRIVER_RETRY_ON_STALE_ELEMENT_EXCEPTION.booleanFrom(environmentVariables, true);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy