use of com.seleniumtests.uipage.htmlelements.PictureElement in project seleniumRobot by bhecquet.
the class TestPictureElement method testPictureNotVisibleWithReplay.
@Test(groups = { "ut" })
public void testPictureNotVisibleWithReplay() throws AWTException {
PictureElement picElement = spy(pictureElement);
picElement.setObjectPictureFile(new File(""));
doReturn(screenshotUtil).when(picElement).getScreenshotUtil();
when(screenshotUtil.capture(SnapshotTarget.PAGE, File.class, true)).thenReturn(new File(""));
doThrow(ImageSearchException.class).when(imageDetector).detectExactZoneWithScale();
Assert.assertFalse(picElement.isElementPresent(350));
verify(picElement, times(2)).findElement();
}
use of com.seleniumtests.uipage.htmlelements.PictureElement 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.uipage.htmlelements.PictureElement in project seleniumRobot by bhecquet.
the class TestPictureElement method testPictureNotVisible.
@Test(groups = { "ut" })
public void testPictureNotVisible() throws AWTException {
PictureElement picElement = spy(pictureElement);
picElement.setObjectPictureFile(new File(""));
when(screenshotUtil.capture(SnapshotTarget.PAGE, File.class, true)).thenReturn(new File(""));
doReturn(screenshotUtil).when(picElement).getScreenshotUtil();
doThrow(ImageSearchException.class).when(imageDetector).detectExactZoneWithScale();
Assert.assertFalse(picElement.isElementPresent());
verify(picElement).findElement();
}
use of com.seleniumtests.uipage.htmlelements.PictureElement in project seleniumRobot by bhecquet.
the class TestPictureElement method testPictureVisible.
@Test(groups = { "ut" })
public void testPictureVisible() throws AWTException {
PictureElement picElement = spy(pictureElement);
PowerMockito.mockStatic(WebUIDriver.class);
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(driver);
when(WebUIDriver.getWebUIDriver(anyBoolean())).thenReturn(uiDriver);
when(uiDriver.getDriver()).thenReturn(driver);
when(((CustomEventFiringWebDriver) driver).getDeviceAspectRatio()).thenReturn(1.0);
picElement.setObjectPictureFile(new File(""));
doReturn(screenshotUtil).when(picElement).getScreenshotUtil();
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.0);
Assert.assertTrue(picElement.isElementPresent(2000));
verify(picElement).findElement();
}
use of com.seleniumtests.uipage.htmlelements.PictureElement in project seleniumRobot by bhecquet.
the class TestPictureElement method testClick.
@Test(groups = { "ut" })
public void testClick() {
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.0);
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.0);
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();
verify(picElement).moveAndClick(intoElement, -65, -60);
}
Aggregations