use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestSelectList method init.
@BeforeMethod(groups = { "ut" })
private void init() throws IOException {
SeleniumTestsContextManager.getThreadContext().setBrowser("firefox");
SeleniumTestsContextManager.getThreadContext().setExplicitWaitTimeout(1);
SeleniumTestsContextManager.getThreadContext().setImplicitWaitTimeout(1);
SeleniumTestsContextManager.getThreadContext().setReplayTimeout(2);
eventDriver = spy(new CustomEventFiringWebDriver(driver));
when(eventDriver.switchTo()).thenReturn(target);
// standard select
when(driver.findElement(By.id("select"))).thenReturn(element);
when(element.getTagName()).thenReturn("select");
when(element.isDisplayed()).thenReturn(true);
when(element.findElements(By.tagName("option"))).thenReturn(Arrays.asList(option1, option2));
// the way Select class search for text and value
when(element.findElements(By.xpath(".//option[normalize-space(.) = \"opt1\"]"))).thenReturn(Arrays.asList(option1));
when(element.findElements(By.xpath(".//option[normalize-space(.) = \"opt2\"]"))).thenReturn(Arrays.asList(option2));
when(element.findElements(By.xpath(".//option[@value = \"opti1\"]"))).thenReturn(Arrays.asList(option1));
when(element.findElements(By.xpath(".//option[@value = \"opti2\"]"))).thenReturn(Arrays.asList(option2));
when(option1.getText()).thenReturn("opt1");
when(option2.getText()).thenReturn("opt2");
when(option1.getAttribute("value")).thenReturn("opti1");
when(option2.getAttribute("value")).thenReturn("opti2");
when(option1.getAttribute("index")).thenReturn("1");
when(option2.getAttribute("index")).thenReturn("2");
// when(driver.getCurrentUrl()).thenReturn("http://foo");
// when(element.getSize()).thenReturn(new Dimension(10, 10));
// when(element.getLocation()).thenReturn(new Point(5, 5));
PowerMockito.mockStatic(WebUIDriver.class);
when(WebUIDriver.getCurrentWebUiDriverName()).thenReturn("main");
when(WebUIDriver.getWebDriver(anyBoolean(), eq(BrowserType.FIREFOX), eq("main"), isNull())).thenReturn(eventDriver);
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(eventDriver);
when(eventDriver.executeScript("if (document.readyState === \"complete\") { return \"ok\"; }")).thenReturn("ok");
when(eventDriver.getBrowserInfo()).thenReturn(new BrowserInfo(BrowserType.FIREFOX, "78.0"));
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestPageObject2 method init.
@BeforeMethod(groups = { "ut" })
private void init() throws IOException {
SeleniumTestsContextManager.getGlobalContext().setCucumberImplementationPackage("com.seleniumtests.ut.core.runner.cucumber");
SeleniumTestsContextManager.getThreadContext().setBrowser("firefox");
SeleniumTestsContextManager.getThreadContext().setExplicitWaitTimeout(1);
SeleniumTestsContextManager.getThreadContext().setImplicitWaitTimeout(1);
SeleniumTestsContextManager.getThreadContext().setReplayTimeout(2);
eventDriver = spy(new CustomEventFiringWebDriver(driver));
when(eventDriver.switchTo()).thenReturn(target);
when(driver.findElement(By.id("el"))).thenReturn(element);
when(driver.navigate()).thenReturn(navigation);
when(driver.getCurrentUrl()).thenReturn("http://foo");
when(driver.manage()).thenReturn(driverOptions);
when(driverOptions.timeouts()).thenReturn(timeouts);
when(element.getSize()).thenReturn(new Dimension(10, 10));
when(element.getLocation()).thenReturn(new Point(5, 5));
when(targetLocator.alert()).thenReturn(alert);
when(alert.getText()).thenReturn("alert text");
when(driver.switchTo()).thenReturn(targetLocator);
PowerMockito.mockStatic(WebUIDriver.class);
when(WebUIDriver.getCurrentWebUiDriverName()).thenReturn("main");
when(WebUIDriver.getWebDriver(anyBoolean(), eq(BrowserType.FIREFOX), eq("main"), isNull())).thenReturn(eventDriver);
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(eventDriver);
when(eventDriver.executeScript("if (document.readyState === \"complete\") { return \"ok\"; }")).thenReturn("ok");
when(eventDriver.getBrowserInfo()).thenReturn(new BrowserInfo(BrowserType.FIREFOX, "78.0"));
when(screenshotUtil.capture(any(SnapshotTarget.class), ArgumentMatchers.<Class<ScreenShot>>any())).thenReturn(screenshot);
when(screenshotUtil.capture(any(SnapshotTarget.class), ArgumentMatchers.<Class<ScreenShot>>any(), anyInt())).thenReturn(screenshot);
when(screenshot.getHtmlSourcePath()).thenReturn("foo");
when(screenshot.getImagePath()).thenReturn("image");
page = new PageForActions();
}
Aggregations