Search in sources :

Example 26 with CustomEventFiringWebDriver

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");
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) ImageSearchException(com.seleniumtests.customexception.ImageSearchException) SkipException(org.testng.SkipException) GenericMultiBrowserTest(com.seleniumtests.it.driver.support.GenericMultiBrowserTest) Test(org.testng.annotations.Test)

Example 27 with CustomEventFiringWebDriver

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");
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) ImageSearchException(com.seleniumtests.customexception.ImageSearchException) SkipException(org.testng.SkipException) GenericMultiBrowserTest(com.seleniumtests.it.driver.support.GenericMultiBrowserTest) Test(org.testng.annotations.Test)

Example 28 with CustomEventFiringWebDriver

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");
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 29 with CustomEventFiringWebDriver

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);
}
Also used : PictureElement(com.seleniumtests.uipage.htmlelements.PictureElement) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Rectangle(org.openqa.selenium.Rectangle) Point(org.openqa.selenium.Point) Dimension(org.openqa.selenium.Dimension) File(java.io.File) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 30 with CustomEventFiringWebDriver

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");
}
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) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)77 Test (org.testng.annotations.Test)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)36 MockitoTest (com.seleniumtests.MockitoTest)35 Dimension (org.openqa.selenium.Dimension)26 WebDriver (org.openqa.selenium.WebDriver)14 GenericDriverTest (com.seleniumtests.GenericDriverTest)12 Point (org.openqa.selenium.Point)12 GenericTest (com.seleniumtests.GenericTest)10 ScenarioException (com.seleniumtests.customexception.ScenarioException)9 WebDriverException (org.openqa.selenium.WebDriverException)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 DriverExceptionListener (com.seleniumtests.driver.DriverExceptionListener)6 SkipException (org.testng.SkipException)6 NLWebDriver (com.neotys.selenium.proxies.NLWebDriver)5 File (java.io.File)5 IOException (java.io.IOException)5 Rectangle (org.openqa.selenium.Rectangle)5 WebElement (org.openqa.selenium.WebElement)5 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)4