Search in sources :

Example 1 with PageForActions

use of com.seleniumtests.ut.core.runner.cucumber.PageForActions 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();
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) SnapshotTarget(com.seleniumtests.driver.screenshots.SnapshotTarget) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Dimension(org.openqa.selenium.Dimension) Point(org.openqa.selenium.Point) PageForActions(com.seleniumtests.ut.core.runner.cucumber.PageForActions) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)1 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)1 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)1 SnapshotTarget (com.seleniumtests.driver.screenshots.SnapshotTarget)1 PageForActions (com.seleniumtests.ut.core.runner.cucumber.PageForActions)1 Dimension (org.openqa.selenium.Dimension)1 Point (org.openqa.selenium.Point)1 BeforeMethod (org.testng.annotations.BeforeMethod)1