@Test void sendKeysShouldImplicitlyWaitForTheElementToBeVisible() { final String text = "To be or not to be"; final WebElement mockedElement = mock(WebElement.class); when(mockedDriver.findElement(By.name("foo"))) .thenReturn(mockedElement); doThrow(ElementNotVisibleException.class) .doThrow(ElementNotVisibleException.class) .doNothing() .when(mockedElement).sendKeys(text); driver.findElement(By.name("foo")).sendKeys(text); assertThat(clock.now(), is(200L)); verify(mockedDriver, times(1)).findElement(By.name("foo")); verify(mockedElement, times(3)).sendKeys(text); }
@Override public WebElement findElement(By locator) { try { return new ImplicitlyWaitingWebElement(trier().tryTo(getOriginal()::findElement, locator), this).getActivated(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (LimitExceededException e) { throw propagate(e.getCause()); } }
ImplicitlyWaitingWebDriver extends DecoratedWebDriver { @Override public WebElement findElement(By locator) { try { return new ImplicitlyWaitingWebElement(trier().tryTo(getOriginal()::findElement, locator), this).getActivated(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (LimitExceededException e) { throw propagate(e.getCause()); } } }
ImplicitlyWaitingWebDriver extends DecoratedWebDriver { @Override public WebElement findElement(By locator) { try { return new ImplicitlyWaitingWebElement(trier().tryTo(getOriginal()::findElement, locator), this).getActivated(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (LimitExceededException e) { throw propagate(e.getCause()); } } ImplicitlyWaitingWebDriver(final WebDriver driver);  ImplicitlyWaitingWebDriver(final WebDriver driver, long timeoutInSeconds);  ImplicitlyWaitingWebDriver(final WebDriver driver, long timeoutInSeconds, long sleepTimeOut); protected  ImplicitlyWaitingWebDriver(final WebDriver driver, Clock clock, Sleeper sleeper, long timeoutInSeconds, long sleepTimeOut); }
ImplicitlyWaitingWebDriver extends DecoratedWebDriver { @Override public WebElement findElement(By locator) { try { return new ImplicitlyWaitingWebElement(trier().tryTo(getOriginal()::findElement, locator), this).getActivated(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (LimitExceededException e) { throw propagate(e.getCause()); } } ImplicitlyWaitingWebDriver(final WebDriver driver);  ImplicitlyWaitingWebDriver(final WebDriver driver, long timeoutInSeconds);  ImplicitlyWaitingWebDriver(final WebDriver driver, long timeoutInSeconds, long sleepTimeOut); protected  ImplicitlyWaitingWebDriver(final WebDriver driver, Clock clock, Sleeper sleeper, long timeoutInSeconds, long sleepTimeOut); @Override WebElement findElement(By locator); @Override List<WebElement> findElements(By locator); }
ImplicitlyWaitingWebDriver extends DecoratedWebDriver { @Override public WebElement findElement(By locator) { try { return new ImplicitlyWaitingWebElement(trier().tryTo(getOriginal()::findElement, locator), this).getActivated(); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (LimitExceededException e) { throw propagate(e.getCause()); } } ImplicitlyWaitingWebDriver(final WebDriver driver);  ImplicitlyWaitingWebDriver(final WebDriver driver, long timeoutInSeconds);  ImplicitlyWaitingWebDriver(final WebDriver driver, long timeoutInSeconds, long sleepTimeOut); protected  ImplicitlyWaitingWebDriver(final WebDriver driver, Clock clock, Sleeper sleeper, long timeoutInSeconds, long sleepTimeOut); @Override WebElement findElement(By locator); @Override List<WebElement> findElements(By locator);  }