use of com.seleniumtests.driver.DriverExceptionListener in project seleniumRobot by bhecquet.
the class TestCustomEventFiringWebDriver method testContentDimensionWithoutScrollbarNonWebTest.
/**
* For non web test, dimension is returned from driver call, not javascript
*/
@Test(groups = { "ut" })
public void testContentDimensionWithoutScrollbarNonWebTest() {
eventDriver = spy(new CustomEventFiringWebDriver(driver, null, null, false, DriverMode.LOCAL, null, null).register(new DriverExceptionListener()));
when(driver.executeScript(anyString(), eq(true))).thenReturn(120L).thenReturn(80L);
Dimension dim = ((CustomEventFiringWebDriver) eventDriver).getViewPortDimensionWithoutScrollbar();
// check we get the window dimension
Assert.assertEquals(dim.height, 100);
Assert.assertEquals(dim.width, 100);
}
use of com.seleniumtests.driver.DriverExceptionListener in project seleniumRobot by bhecquet.
the class TestCustomEventFiringWebDriver method testScrollPositionNonWebTest.
/**
* For non web test, dimension is returned from driver call, not javascript
*/
@Test(groups = { "ut" }, expectedExceptions = WebDriverException.class)
public void testScrollPositionNonWebTest() {
eventDriver = spy(new CustomEventFiringWebDriver(driver, null, null, false, DriverMode.LOCAL, null, null).register(new DriverExceptionListener()));
when(driver.executeScript(anyString())).thenReturn(Arrays.asList(120L, 80L));
((CustomEventFiringWebDriver) eventDriver).getScrollPosition();
}
use of com.seleniumtests.driver.DriverExceptionListener 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.DriverExceptionListener in project seleniumRobot by bhecquet.
the class TestActions method init.
@BeforeMethod(groups = { "ut" })
private void init() throws WebDriverException, IOException {
SeleniumTestsContextManager.getGlobalContext().setCucumberImplementationPackage("com.seleniumtests.ut.core.runner.cucumber");
// mimic sub elements of the HtmlElement
List<WebElement> subElList = new ArrayList<WebElement>();
subElList.add(subElement1);
subElList.add(subElement2);
// list of elements correspond
List<WebElement> elList = new ArrayList<WebElement>();
elList.add(element);
// add DriverExceptionListener to reproduce driver behavior
eventDriver = spy(new CustomEventFiringWebDriver(driver).register(new DriverExceptionListener()));
PowerMockito.mockStatic(WebUIDriver.class);
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(eventDriver);
when(WebUIDriver.getWebDriver(anyBoolean(), any(BrowserType.class), isNull(), isNull())).thenReturn(eventDriver);
when(WebUIDriver.getWebUIDriver(anyBoolean())).thenReturn(uiDriver);
when(driver.navigate()).thenReturn(navigation);
when(driver.switchTo()).thenReturn(locator);
when(eventDriver.switchTo()).thenReturn(locator);
SeleniumTestsContextManager.getThreadContext().setTestType(TestType.WEB);
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
}
use of com.seleniumtests.driver.DriverExceptionListener in project seleniumRobot by bhecquet.
the class TestCustomEventFiringWebDriver method testContentDimensionNonWebTest.
/**
* For non web test, dimension is returned from driver call, not javascript
*/
@Test(groups = { "ut" })
public void testContentDimensionNonWebTest() {
eventDriver = spy(new CustomEventFiringWebDriver(driver, null, null, false, DriverMode.LOCAL, null, null).register(new DriverExceptionListener()));
when(driver.executeScript(anyString())).thenReturn(Arrays.asList(120L, 80L));
Dimension dim = ((CustomEventFiringWebDriver) eventDriver).getContentDimension();
// check we get the window dimension
Assert.assertEquals(dim.height, 100);
Assert.assertEquals(dim.width, 100);
}
Aggregations