Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and extend timeout durations #3263

Merged
merged 1 commit into from
Jan 31, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@
* as well as performing common page actions like logging out and clearing cookies.
*/
public class Page {

// This is the global setting that selenium waits during operations.
// It should be small, as changing this value will increase the time tests take to run.
protected static final Duration IMPLICIT_WAIT_SECONDS = Duration.ofSeconds(5);

// This is used to control the max time that awaitility will check to see if
// an assertion passes, before failing the test.
protected static final Duration AWAIT_AT_MOST_SECONDS = Duration.ofSeconds(30);

protected WebDriver driver;

public Page(WebDriver driver) {
this.driver = driver;
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
driver.manage().timeouts().implicitlyWait(IMPLICIT_WAIT_SECONDS);
}

public static AbstractStringAssert<?> assertThatUrlEventuallySatisfies(WebDriver driver, Consumer<AbstractStringAssert<?>> assertUrl) {
await().atMost(Duration.ofSeconds(5))
await().atMost(AWAIT_AT_MOST_SECONDS)
.untilAsserted(() -> assertUrl.accept(assertThatUrl(driver)));
return assertThatUrl(driver);
}
Expand All @@ -34,7 +43,7 @@ private static AbstractStringAssert<?> assertThatUrl(WebDriver driver) {
}

public AbstractStringAssert<?> assertThatUrlEventuallySatisfies(Consumer<AbstractStringAssert<?>> assertUrl) {
await().atMost(Duration.ofSeconds(5))
await().atMost(AWAIT_AT_MOST_SECONDS)
.untilAsserted(() -> assertUrl.accept(assertThatUrl(driver)));
return assertThatUrl();
}
Expand Down
Loading