Add tests for Duration-based WebDriverWait constructors
Add tests for
import org.openqa.selenium.remote.SessionId;
import java.io.IOException;
+import java.time.Duration;
public class WebDriverWaitTest {
@@ -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))
@@ -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));
@@ -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);
}
@@ -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);
}
@@ -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);
}
}
