use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestCustomEventFiringWebDriver method init.
@BeforeMethod(groups = { "ut" })
private void init() throws Exception {
PowerMockito.spy(CustomEventFiringWebDriver.class);
// add DriverExceptionListener to reproduce driver behavior
eventDriver = spy(new CustomEventFiringWebDriver(driver, null, browserInfo, true, DriverMode.LOCAL, null, null).register(new DriverExceptionListener()));
attachedEventDriver = spy(new CustomEventFiringWebDriver(driver, null, browserInfo, true, DriverMode.LOCAL, null, null, 12345).register(new DriverExceptionListener()));
when(driver.manage()).thenReturn(options);
when(driver.getCapabilities()).thenReturn(capabilities);
when(driver.switchTo()).thenReturn(target);
when(driver.getSessionId()).thenReturn(new SessionId("1234"));
when(driver.getPageSource()).thenReturn("<html></html>");
when(options.window()).thenReturn(window);
when(window.getSize()).thenReturn(new Dimension(100, 100));
PowerMockito.mockStatic(OSUtilityFactory.class);
when(OSUtilityFactory.getInstance()).thenReturn(osUtility);
PowerMockito.whenNew(Robot.class).withNoArguments().thenReturn(robot);
PowerMockito.whenNew(VideoRecorder.class).withAnyArguments().thenReturn(videoRecorder);
PowerMockito.whenNew(Keyboard.class).withNoArguments().thenReturn(keyboard);
PowerMockito.doReturn(new Rectangle(1900, 1000)).when(CustomEventFiringWebDriver.class, "getScreensRectangle");
PowerMockito.mockStatic(MouseInfo.class);
PowerMockito.when(MouseInfo.getPointerInfo()).thenReturn(pointerInfo);
when(pointerInfo.getLocation()).thenReturn(new java.awt.Point(2, 3));
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestCustomEventFiringWebDriver method testViewPortDimensionWithoutScrollbar.
/**
* Check standard web case where dimension comes from javascript call
*/
@Test(groups = { "ut" })
public void testViewPortDimensionWithoutScrollbar() {
when(driver.executeScript(anyString(), eq(true))).thenReturn(120L).thenReturn(80L);
Dimension dim = ((CustomEventFiringWebDriver) eventDriver).getViewPortDimensionWithoutScrollbar();
// no need to switch to default content if size is correctly returned
verify(driver, never()).switchTo();
// check we get the window dimension
Assert.assertEquals(dim.height, 80);
Assert.assertEquals(dim.width, 120);
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testDriverCreationWithVideoInError.
@Test(groups = { "ut" })
public void testDriverCreationWithVideoInError() throws Exception {
SeleniumTestsContextManager.getThreadContext().setVideoCapture("true");
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
PowerMockito.mockStatic(CustomEventFiringWebDriver.class);
PowerMockito.doThrow(new ScenarioException("error")).when(CustomEventFiringWebDriver.class, "startVideoCapture", eq(DriverMode.LOCAL), eq(null), any(File.class), eq("videoCapture.avi"));
WebDriver driver = WebUIDriver.getWebDriver(true);
Assert.assertTrue(driver instanceof CustomEventFiringWebDriver);
Assert.assertNull(WebUIDriver.getVideoRecorder().get());
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testDriverCreationWithDefaultType.
/**
* If BrowserType is not given, the type is taken from context parameter
*/
@Test(groups = { "ut" })
public void testDriverCreationWithDefaultType() {
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
WebDriver driver1 = WebUIDriver.getWebDriver(true, null, "main", null);
Assert.assertTrue(((CustomEventFiringWebDriver) driver1).getWebDriver() instanceof HtmlUnitDriver);
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testDriverCreationWithNeoload.
/**
* Check that when user requests for neoload, it's driver is added
*/
@Test(groups = { "ut" })
public void testDriverCreationWithNeoload() {
PowerMockito.mockStatic(NLWebDriverFactory.class);
PowerMockito.when(NLWebDriverFactory.newNLWebDriver(any(WebDriver.class), anyString())).thenReturn(neoloadDriver);
try {
SeleniumTestsContextManager.getThreadContext().setNeoloadUserPath("path");
System.setProperty("nl.selenium.proxy.mode", "Design");
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
WebDriver driver = WebUIDriver.getWebDriver(true);
Assert.assertTrue(driver instanceof CustomEventFiringWebDriver);
Assert.assertNotNull(((CustomEventFiringWebDriver) driver).getNeoloadDriver());
} finally {
System.clearProperty("nl.selenium.proxy.mode");
}
}
Aggregations