Search in sources :

Example 6 with ScreenZone

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

the class TestScreenZone method testPictureVisible.

@Test(groups = { "ut" })
public void testPictureVisible() 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(""));
    when(imageDetector.getDetectedRectangle()).thenReturn(new Rectangle(10, 10, 100, 50));
    when(imageDetector.getSizeRatio()).thenReturn(1.0);
    Assert.assertTrue(picElement.isElementPresent(2000));
    verify(picElement).findElement();
}
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 7 with ScreenZone

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

the class TestScreenZone method testDoubleClick.

@Test(groups = { "ut" })
public void testDoubleClick() {
    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.doubleClickAt(0, 0);
    verify(picElement).moveAndDoubleClick(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 8 with ScreenZone

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

the class TestScreenZone method testSendKeys.

@Test(groups = { "ut" })
public void testSendKeys() {
    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.sendKeys(0, 0, KeyEvent.VK_0);
    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 9 with ScreenZone

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

the class TestScreenZone method testPictureNotVisibleWithReplay.

@Test(groups = { "ut" })
public void testPictureNotVisibleWithReplay() 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(350));
    verify(picElement, times(2)).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