use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestScreenZone method testSendKeyboardKeysOnPicture.
@Test(groups = { "it" })
public void testSendKeyboardKeysOnPicture() {
try {
DriverTestPageWithoutFixedPattern.logoText.clear();
((CustomEventFiringWebDriver) driver).scrollToElement(DriverTestPageWithoutFixedPattern.table, 200);
DriverTestPageWithoutFixedPattern.firefoxForDesktop.sendKeys(0, 40, KeyEvent.VK_A, KeyEvent.VK_B);
} catch (ImageSearchException e) {
throw new SkipException("Image not found, we may be on screenless slave", e);
}
Assert.assertEquals(DriverTestPageWithoutFixedPattern.logoText.getValue(), "ab");
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestScreenZone method testSendKeysOnPicture.
@Test(groups = { "it" })
public void testSendKeysOnPicture() {
try {
DriverTestPageWithoutFixedPattern.logoText.clear();
((CustomEventFiringWebDriver) driver).scrollToElement(DriverTestPageWithoutFixedPattern.table, 200);
DriverTestPageWithoutFixedPattern.firefoxForDesktop.sendKeys(0, 40, "hello");
} catch (ImageSearchException e) {
throw new SkipException("Image not found, we may be on screenless slave", e);
}
Assert.assertEquals(DriverTestPageWithoutFixedPattern.logoText.getValue(), "hello");
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestHtmlElement method testZoom.
@Test(groups = { "ut" })
public void testZoom() throws Exception {
SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_WEB_ANDROID);
SeleniumTestsContextManager.getThreadContext().setPlatform("android");
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(new CustomEventFiringWebDriver(mobileDriver));
doNothing().when(el).findElement(anyBoolean(), anyBoolean());
el.setElement(mobileElement);
el.zoom();
PowerMockito.verifyPrivate(el, atLeastOnce()).invoke("checkForMobile");
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestPictureElement method testClickOtherPixelRatio.
@Test(groups = { "ut" })
public void testClickOtherPixelRatio() {
PictureElement picElement = spy(pictureElement);
picElement.setObjectPictureFile(new File(""));
PowerMockito.mockStatic(WebUIDriver.class);
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(driver);
when(WebUIDriver.getWebUIDriver(anyBoolean())).thenReturn(uiDriver);
when(uiDriver.getDriver()).thenReturn(driver);
when(uiDriver.getConfig()).thenReturn(driverConfig);
when(driverConfig.getBrowserType()).thenReturn(BrowserType.FIREFOX);
when(driver.getMouse()).thenReturn(mouse);
when(driver.getKeyboard()).thenReturn(keyboard);
when(driver.getBrowserInfo()).thenReturn(browserInfo);
when(((CustomEventFiringWebDriver) driver).getDeviceAspectRatio()).thenReturn(1.5);
when(browserInfo.getBrowser()).thenReturn(BrowserType.FIREFOX);
when(screenshotUtil.capture(SnapshotTarget.PAGE, File.class, true)).thenReturn(new File(""));
when(imageDetector.getDetectedRectangle()).thenReturn(new Rectangle(10, 10, 100, 50));
when(imageDetector.getSizeRatio()).thenReturn(1.5);
when(coordinates.inViewPort()).thenReturn(new Point(100, 120));
when(coordinates.onPage()).thenReturn(new Point(100, 120));
when(intoElement.getCoordinates()).thenReturn(coordinates);
when(intoElement.getSize()).thenReturn(new Dimension(200, 200));
doReturn(screenshotUtil).when(picElement).getScreenshotUtil();
picElement.click();
// as pixel ratio changed, real rectangle is different
verify(picElement).moveAndClick(intoElement, -78, -81);
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestSelectList2 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("select"))).thenReturn(element);
when(driver.navigate()).thenReturn(navigation);
when(driver.getCurrentUrl()).thenReturn("http://foo");
when(driver.manage()).thenReturn(driverOptions);
when(element.getTagName()).thenReturn("select");
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(screenshot.getHtmlSourcePath()).thenReturn("foo");
}
Aggregations