Search in sources :

Example 71 with BrowserInfo

use of com.seleniumtests.browserfactory.BrowserInfo 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)71 Test (org.testng.annotations.Test)59 MockitoTest (com.seleniumtests.MockitoTest)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)53 ArrayList (java.util.ArrayList)23 List (java.util.List)19 BrowserType (com.seleniumtests.driver.BrowserType)18 HashMap (java.util.HashMap)14 MutableCapabilities (org.openqa.selenium.MutableCapabilities)9 GenericDriverTest (com.seleniumtests.GenericDriverTest)6 ChromeCapabilitiesFactory (com.seleniumtests.browserfactory.ChromeCapabilitiesFactory)5 EdgeCapabilitiesFactory (com.seleniumtests.browserfactory.EdgeCapabilitiesFactory)5 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 EnumMap (java.util.EnumMap)3 Map (java.util.Map)3 SkipException (org.testng.SkipException)3 FirefoxCapabilitiesFactory (com.seleniumtests.browserfactory.FirefoxCapabilitiesFactory)2 IECapabilitiesFactory (com.seleniumtests.browserfactory.IECapabilitiesFactory)2 MobileDevice (com.seleniumtests.browserfactory.mobile.MobileDevice)2