From a8e1a2bc460fd21974fbd8a184281e5ff254fd1f Mon Sep 17 00:00:00 2001 From: Kurt Alfred Kluever Date: Thu, 16 May 2019 10:54:25 -0400 Subject: [PATCH] Add tests for Duration-based WebDriverWait constructors Add tests for https://github.com/SeleniumHQ/selenium/issues/7187 --- .../selenium/support/ui/WebDriverWaitTest.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java b/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java index d8ec4e6f6dbe5..5504a9152a7f5 100644 --- a/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java +++ b/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java @@ -44,6 +44,7 @@ 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 wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); + Wait 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 wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); + Wait 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 wait = new WebDriverWait(mockDriver, clock, clock, 5, 500); + Wait wait = + new WebDriverWait(mockDriver, Duration.ofSeconds(5), Duration.ofMillis(500), clock, clock); wait.until(condition); } }