Search in sources :

Example 1 with ScreenZone

use of com.seleniumtests.uipage.htmlelements.ScreenZone in project seleniumRobot by bhecquet.

the class TestScreenZone method testDoubleClickAtCoordinates.

/**
 * Clic at given coordinate on screen without picture reference
 */
@Test(groups = { "it" })
public void testDoubleClickAtCoordinates() {
    try {
        // search zone to click
        DriverTestPageWithoutFixedPattern.googleForDesktop.findElement();
        Rectangle rectangle = DriverTestPageWithoutFixedPattern.googleForDesktop.getDetectedObjectRectangle();
        // clic with a new ScreenZone
        new ScreenZone("image").doubleClickAt(rectangle.x + 10, rectangle.y + 10);
    } catch (ImageSearchException e) {
        throw new SkipException("Image not found, we may be on screenless slave", e);
    }
    Assert.assertEquals(DriverTestPageWithoutFixedPattern.textElement.getValue(), "double click image");
}
Also used : ImageSearchException(com.seleniumtests.customexception.ImageSearchException) Rectangle(org.openqa.selenium.Rectangle) SkipException(org.testng.SkipException) ScreenZone(com.seleniumtests.uipage.htmlelements.ScreenZone) GenericMultiBrowserTest(com.seleniumtests.it.driver.support.GenericMultiBrowserTest) Test(org.testng.annotations.Test)

Example 2 with ScreenZone

use of com.seleniumtests.uipage.htmlelements.ScreenZone in project seleniumRobot by bhecquet.

the class TestScreenZone method testClickAtCoordinates.

/**
 * Clic at given coordinate on screen without picture reference
 */
@Test(groups = { "it" })
public void testClickAtCoordinates() {
    try {
        // search zone to click
        DriverTestPageWithoutFixedPattern.googleForDesktop.findElement();
        Rectangle rectangle = DriverTestPageWithoutFixedPattern.googleForDesktop.getDetectedObjectRectangle();
        // clic with a new ScreenZone
        new ScreenZone("image").clickAt(rectangle.x + 10, rectangle.y + 10);
    } catch (ImageSearchException e) {
        throw new SkipException("Image not found, we may be on screenless slave", e);
    }
    Assert.assertEquals(DriverTestPageWithoutFixedPattern.textElement.getValue(), "image");
}
Also used : ImageSearchException(com.seleniumtests.customexception.ImageSearchException) Rectangle(org.openqa.selenium.Rectangle) SkipException(org.testng.SkipException) ScreenZone(com.seleniumtests.uipage.htmlelements.ScreenZone) GenericMultiBrowserTest(com.seleniumtests.it.driver.support.GenericMultiBrowserTest) Test(org.testng.annotations.Test)

Example 3 with ScreenZone

use of com.seleniumtests.uipage.htmlelements.ScreenZone in project seleniumRobot by bhecquet.

the class TestScreenZone method testRightClick.

@Test(groups = { "ut" })
public void testRightClick() {
    ScreenZone picElement = spy(screenZone);
    picElement.setObjectPictureFile(new File(""));
    PowerMockito.mockStatic(CustomEventFiringWebDriver.class);
    PowerMockito.mockStatic(WebUIDriver.class);
    when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(driver);
    when(driver.getBrowserInfo()).thenReturn(browserInfo);
    when(browserInfo.getBrowser()).thenReturn(BrowserType.FIREFOX);
    doReturn(screenshotUtil).when(picElement).getScreenshotUtil();
    when(screenshotUtil.capture(SnapshotTarget.SCREEN, File.class, true)).thenReturn(new File(""));
    when(imageDetector.getDetectedRectangle()).thenReturn(new Rectangle(10, 10, 100, 50));
    when(imageDetector.getSizeRatio()).thenReturn(1.0);
    picElement.rightClickAt(0, 0);
    verify(picElement).moveAndRightClick(35, 60);
}
Also used : Rectangle(org.openqa.selenium.Rectangle) ScreenZone(com.seleniumtests.uipage.htmlelements.ScreenZone) File(java.io.File) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 4 with ScreenZone

use of com.seleniumtests.uipage.htmlelements.ScreenZone in project seleniumRobot by bhecquet.

the class TestScreenZone method testClick.

@Test(groups = { "ut" })
public void testClick() {
    ScreenZone picElement = spy(screenZone);
    picElement.setObjectPictureFile(new File(""));
    PowerMockito.mockStatic(CustomEventFiringWebDriver.class);
    PowerMockito.mockStatic(WebUIDriver.class);
    when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(driver);
    when(driver.getBrowserInfo()).thenReturn(browserInfo);
    when(browserInfo.getBrowser()).thenReturn(BrowserType.FIREFOX);
    doReturn(screenshotUtil).when(picElement).getScreenshotUtil();
    when(screenshotUtil.capture(SnapshotTarget.SCREEN, File.class, true)).thenReturn(new File(""));
    when(imageDetector.getDetectedRectangle()).thenReturn(new Rectangle(10, 10, 100, 50));
    when(imageDetector.getSizeRatio()).thenReturn(1.0);
    picElement.click();
    verify(picElement).moveAndLeftClick(35, 60);
}
Also used : Rectangle(org.openqa.selenium.Rectangle) ScreenZone(com.seleniumtests.uipage.htmlelements.ScreenZone) File(java.io.File) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 5 with ScreenZone

use of com.seleniumtests.uipage.htmlelements.ScreenZone in project seleniumRobot by bhecquet.

the class TestScreenZone method testPictureNotVisible.

@Test(groups = { "ut" })
public void testPictureNotVisible() throws AWTException {
    ScreenZone picElement = spy(screenZone);
    picElement.setObjectPictureFile(new File(""));
    doReturn(screenshotUtil).when(picElement).getScreenshotUtil();
    when(screenshotUtil.capture(SnapshotTarget.SCREEN, File.class, true)).thenReturn(new File(""));
    doThrow(ImageSearchException.class).when(imageDetector).detectExactZoneWithScale();
    Assert.assertFalse(picElement.isElementPresent());
    verify(picElement).findElement();
}
Also used : ScreenZone(com.seleniumtests.uipage.htmlelements.ScreenZone) File(java.io.File) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

ScreenZone (com.seleniumtests.uipage.htmlelements.ScreenZone)9 Test (org.testng.annotations.Test)9 MockitoTest (com.seleniumtests.MockitoTest)7 File (java.io.File)7 Rectangle (org.openqa.selenium.Rectangle)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 ImageSearchException (com.seleniumtests.customexception.ImageSearchException)2 GenericMultiBrowserTest (com.seleniumtests.it.driver.support.GenericMultiBrowserTest)2 SkipException (org.testng.SkipException)2