Skip to content

Commit

Permalink
Add tests for Duration-based WebDriverWait constructors
Browse files Browse the repository at this point in the history
Add tests for #7187
  • Loading branch information
kluever authored and shs96c committed May 17, 2019
1 parent 55fbedc commit a8e1a2b
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.openqa.selenium.remote.SessionId;

import java.io.IOException;
import java.time.Duration;

public class WebDriverWaitTest {

Expand All @@ -68,7 +69,8 @@ public void shouldIncludeRemoteInfoForWrappedDriverTimeout() throws IOException
when(((WrapsDriver) testDriver).getWrappedDriver()).thenReturn(driver);

TickingClock clock = new TickingClock();
WebDriverWait wait = new WebDriverWait(testDriver, clock, clock, 1, 200);
WebDriverWait wait =
new WebDriverWait(testDriver, Duration.ofSeconds(1), Duration.ofMillis(200), clock, clock);

assertThatExceptionOfType(TimeoutException.class)
.isThrownBy(() -> wait.until((d) -> false))
Expand All @@ -79,7 +81,8 @@ public void shouldIncludeRemoteInfoForWrappedDriverTimeout() throws IOException
@Test
public void shouldThrowAnExceptionIfTheTimerRunsOut() {
TickingClock clock = new TickingClock();
WebDriverWait wait = new WebDriverWait(mockDriver, clock, clock, 1, 200);
WebDriverWait wait =
new WebDriverWait(testDriver, Duration.ofSeconds(1), Duration.ofMillis(200), clock, clock);

assertThatExceptionOfType(TimeoutException.class)
.isThrownBy(() -> wait.until((d) -> false));
Expand All @@ -94,7 +97,8 @@ public void shouldSilentlyCaptureNoSuchElementExceptions() {
.thenReturn(mockElement);

TickingClock clock = new TickingClock();
Wait<WebDriver> wait = new WebDriverWait(mockDriver, clock, clock, 5, 500);
Wait<WebDriver> wait =
new WebDriverWait(mockDriver, Duration.ofSeconds(5), Duration.ofMillis(500), clock, clock);
assertThat(wait.until(condition)).isSameAs(mockElement);
}

Expand All @@ -107,7 +111,8 @@ public void shouldSilentlyCaptureNoSuchFrameExceptions() {
.thenReturn(mockElement);

TickingClock clock = new TickingClock();
Wait<WebDriver> wait = new WebDriverWait(mockDriver, clock, clock, 5, 500);
Wait<WebDriver> wait =
new WebDriverWait(mockDriver, Duration.ofSeconds(5), Duration.ofMillis(500), clock, clock);
wait.until(condition);
}

Expand All @@ -121,7 +126,8 @@ public void shouldSilentlyCaptureNoSuchWindowExceptions() {
.thenReturn(mockElement);

TickingClock clock = new TickingClock();
Wait<WebDriver> wait = new WebDriverWait(mockDriver, clock, clock, 5, 500);
Wait<WebDriver> wait =
new WebDriverWait(mockDriver, Duration.ofSeconds(5), Duration.ofMillis(500), clock, clock);
wait.until(condition);
}
}

0 comments on commit a8e1a2b

Please sign in to comment.