Search in sources :

Example 1 with ImageSearchException

use of com.seleniumtests.customexception.ImageSearchException in project seleniumRobot by bhecquet.

the class TestScreenZone method testClickOnGooglePictureWithCaptureSnapshotFalse.

/**
 * Check that "captureSnapshot=false" do not prevent to use ScreenZone
 */
@Test(groups = { "it" })
public void testClickOnGooglePictureWithCaptureSnapshotFalse() {
    try {
        SeleniumTestsContextManager.getThreadContext().setCaptureSnapshot(false);
        DriverTestPageWithoutFixedPattern.googleForDesktop.click();
    } catch (ImageSearchException e) {
        throw new SkipException("Image not found, we may be on screenless slave", e);
    } finally {
        SeleniumTestsContextManager.getThreadContext().setCaptureSnapshot(SeleniumTestsContext.DEFAULT_CAPTURE_SNAPSHOT);
    }
    Assert.assertEquals(DriverTestPageWithoutFixedPattern.textElement.getValue(), "image");
}
Also used : ImageSearchException(com.seleniumtests.customexception.ImageSearchException) SkipException(org.testng.SkipException) GenericMultiBrowserTest(com.seleniumtests.it.driver.support.GenericMultiBrowserTest) Test(org.testng.annotations.Test)

Example 2 with ImageSearchException

use of com.seleniumtests.customexception.ImageSearchException 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 3 with ImageSearchException

use of com.seleniumtests.customexception.ImageSearchException 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 4 with ImageSearchException

use of com.seleniumtests.customexception.ImageSearchException 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 5 with ImageSearchException

use of com.seleniumtests.customexception.ImageSearchException 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)

Aggregations

ImageSearchException (com.seleniumtests.customexception.ImageSearchException)21 SkipException (org.testng.SkipException)17 GenericMultiBrowserTest (com.seleniumtests.it.driver.support.GenericMultiBrowserTest)6 Test (org.testng.annotations.Test)6 KeyPoint (org.opencv.core.KeyPoint)4 MatOfKeyPoint (org.opencv.core.MatOfKeyPoint)4 Point (org.opencv.core.Point)4 IOException (java.io.IOException)3 Mat (org.opencv.core.Mat)3 Rectangle (org.openqa.selenium.Rectangle)3 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)2 ScreenZone (com.seleniumtests.uipage.htmlelements.ScreenZone)2 Scalar (org.opencv.core.Scalar)2 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 File (java.io.File)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 ExecutorService (java.util.concurrent.ExecutorService)1 MinMaxLocResult (org.opencv.core.Core.MinMaxLocResult)1