use of org.openqa.selenium.WebDriver.Timeouts in project vividus by vividus-framework.
the class WebDriverFactoryTests method testGetRemoteWebDriverFirefoxDriver.
@Test
@SuppressWarnings("unchecked")
void testGetRemoteWebDriverFirefoxDriver() throws MalformedURLException {
mockCapabilities(remoteWebDriver);
setRemoteDriverUrl();
DesiredCapabilities desiredCapabilities = new DesiredCapabilities(new FirefoxOptions());
when(remoteWebDriverFactory.getRemoteWebDriver(eq(URL.toURL()), argThat(caps -> {
Map<String, Object> options = (Map<String, Object>) caps.getCapability(FirefoxOptions.FIREFOX_OPTIONS);
Map<String, Object> prefs = (Map<String, Object>) options.get("prefs");
return "about:blank".equals(prefs.get("startup.homepage_welcome_url.additional")) && "firefox".equals(caps.getBrowserName());
}))).thenReturn(remoteWebDriver);
Timeouts timeouts = mockTimeouts(remoteWebDriver);
assertEquals(remoteWebDriver, ((WrapsDriver) webDriverFactory.getRemoteWebDriver(desiredCapabilities)).getWrappedDriver());
verify(timeoutConfigurer).configure(timeouts);
assertLogger("{%n \"acceptInsecureCerts\" : true,%n" + " \"browserName\" : \"firefox\",%n" + " \"moz:debuggerAddress\" : true,%n" + " \"moz:firefoxOptions\" : {%n" + " \"prefs\" : {%n" + " \"startup.homepage_welcome_url.additional\" : \"about:blank\"%n" + " }%n }%n}");
}
use of org.openqa.selenium.WebDriver.Timeouts in project vividus by vividus-framework.
the class WebDriverFactoryTests method testGetRemoteWebDriverIEDriver.
@Test
void testGetRemoteWebDriverIEDriver() throws MalformedURLException {
mockCapabilities(remoteWebDriver);
setRemoteDriverUrl();
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setBrowserName(Browser.IE.browserName());
when(remoteWebDriverFactory.getRemoteWebDriver(any(URL.class), any(DesiredCapabilities.class))).thenReturn(remoteWebDriver);
Timeouts timeouts = mockTimeouts(remoteWebDriver);
desiredCapabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
assertEquals(remoteWebDriver, ((WrapsDriver) webDriverFactory.getRemoteWebDriver(desiredCapabilities)).getWrappedDriver());
verify(timeoutConfigurer).configure(timeouts);
assertLogger();
}
use of org.openqa.selenium.WebDriver.Timeouts in project vividus by vividus-framework.
the class TimeoutConfigurerTests method testSetPageLoadTimeout.
@Test
void testSetPageLoadTimeout() {
Timeouts timeouts = mock(Timeouts.class);
timeoutConfigurer.configurePageLoadTimeout(DURATION_PAGE_LOAD_TIMEOUT, timeouts);
verify(timeouts).pageLoadTimeout(DURATION_PAGE_LOAD_TIMEOUT.getSeconds(), TimeUnit.SECONDS);
}
use of org.openqa.selenium.WebDriver.Timeouts in project vividus by vividus-framework.
the class TimeoutConfigurerTests method testSetTimeoutsWithExceptionAtPageLoadTimeoutSetting.
@Test
void testSetTimeoutsWithExceptionAtPageLoadTimeoutSetting() {
Timeouts timeouts = mock(Timeouts.class);
UnsupportedCommandException exception = new UnsupportedCommandException("pagetimeout");
when(timeouts.pageLoadTimeout(PAGE_LOAD_TIMEOUT, PAGE_LOAD_TIMEOUT_TIMEUNIT)).thenThrow(exception);
timeoutConfigurer.configure(timeouts);
verify(timeouts).setScriptTimeout(ASYNC_SCRIPT_TIMEOUT, ASYNC_SCRIPT_TIMEOUT_TIMEUNIT);
}
use of org.openqa.selenium.WebDriver.Timeouts in project vividus by vividus-framework.
the class WebDriverFactoryTests method mockTimeouts.
private static Timeouts mockTimeouts(WebDriver webDriver) {
Options options = mock(Options.class);
when(webDriver.manage()).thenReturn(options);
Timeouts timeouts = mock(Timeouts.class);
when(options.timeouts()).thenReturn(timeouts);
return timeouts;
}
Aggregations