Search in sources :

Example 6 with ImageDetector

use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.

the class TestImageDetector method searchNonCorrespondingPicture.

/**
 * Search an image inside an other one but no corresponding zone should be found
 * @throws IOException
 */
@Test(groups = { "ut" }, expectedExceptions = ImageSearchException.class, enabled = false)
public void searchNonCorrespondingPicture() throws IOException {
    ImageDetector detector = new ImageDetector(createFileFromResource("tu/images/p9.png"), createFileFromResource("tu/images/creditMutuelLogo.png"));
    detector.detectCorrespondingZone();
}
Also used : ImageDetector(com.seleniumtests.util.imaging.ImageDetector) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 7 with ImageDetector

use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.

the class TestImageDetector method searchWithBlackPicture.

/**
 * Search an image inside an other one but no corresponding zone should be found
 * @throws IOException
 */
@Test(groups = { "ut" }, expectedExceptions = ImageSearchException.class, enabled = false)
public void searchWithBlackPicture() throws IOException {
    ImageDetector detector = new ImageDetector(createFileFromResource("tu/images/blackScreen.png"), createFileFromResource("tu/images/creditMutuelLogo.png"));
    detector.detectCorrespondingZone();
}
Also used : ImageDetector(com.seleniumtests.util.imaging.ImageDetector) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 8 with ImageDetector

use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.

the class TestImageDetector method searchExactPictureNoScaling.

@Test(groups = { "ut" })
public void searchExactPictureNoScaling() throws IOException {
    ImageDetector detector = new ImageDetector(createFileFromResource("tu/images/p9.png"), createFileFromResource("tu/images/vosAlertes.png"));
    detector.detectExactZoneWithoutScale();
    Rectangle detectedRectangle = detector.getDetectedRectangle();
    Assert.assertEquals(detectedRectangle, new Rectangle(575, 137, 30, 108));
}
Also used : ImageDetector(com.seleniumtests.util.imaging.ImageDetector) Rectangle(org.openqa.selenium.Rectangle) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 9 with ImageDetector

use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.

the class TestImageDetector method searchPicturesByTemplate2.

@Test(groups = { "ut" })
public void searchPicturesByTemplate2() throws IOException {
    ImageDetector detector = new ImageDetector(createFileFromResource("tu/images/infolidays.png"), createFileFromResource("tu/images/bouton_enregistrer2.png"), 0.06);
    detector.detectExactZoneWithScale();
    Assert.assertEquals(detector.getDetectedRectangle(), new Rectangle(69, 1609, 185, 1299));
    Assert.assertEquals(detector.getSizeRatio(), 1.2, 0.05);
}
Also used : ImageDetector(com.seleniumtests.util.imaging.ImageDetector) Rectangle(org.openqa.selenium.Rectangle) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 10 with ImageDetector

use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.

the class TestBrowserSnapshot method testCaptureAllPage.

/**
 * Check we can rebuild the whole page from partial captures
 * This is useful for chrome as snapshot is only taken from visible display
 * For firefox, nothing to do
 * @throws IOException
 */
@Test(groups = { "it" })
public void testCaptureAllPage() throws IOException {
    driver.manage().window().setSize(new Dimension(400, 300));
    WaitHelper.waitForSeconds(1);
    String topFilePath = generateCaptureFilePath();
    FileUtility.writeImage(topFilePath, new ScreenshotUtil(driver).capturePage(0, 0));
    // get full picture
    File image = new ScreenshotUtil(driver).capture(SnapshotTarget.PAGE, File.class);
    String bottomFilePath = generateCaptureFilePath();
    FileUtility.writeImage(bottomFilePath, new ScreenshotUtil(driver).capturePage(0, 0));
    // exception thrown if nothing found
    ImageDetector detectorTop = new ImageDetector(image, new File(topFilePath), 0.001);
    detectorTop.detectExactZoneWithScale();
}
Also used : ScreenshotUtil(com.seleniumtests.driver.screenshots.ScreenshotUtil) ImageDetector(com.seleniumtests.util.imaging.ImageDetector) Dimension(org.openqa.selenium.Dimension) File(java.io.File) Test(org.testng.annotations.Test) GenericMultiBrowserTest(com.seleniumtests.it.driver.support.GenericMultiBrowserTest)

Aggregations

ImageDetector (com.seleniumtests.util.imaging.ImageDetector)20 Test (org.testng.annotations.Test)18 GenericTest (com.seleniumtests.GenericTest)17 Rectangle (org.openqa.selenium.Rectangle)13 File (java.io.File)3 BufferedImage (java.awt.image.BufferedImage)2 IOException (java.io.IOException)2 ScreenshotException (org.openqa.selenium.remote.ScreenshotException)2 ScreenshotUtil (com.seleniumtests.driver.screenshots.ScreenshotUtil)1 GenericMultiBrowserTest (com.seleniumtests.it.driver.support.GenericMultiBrowserTest)1 Rectangle (java.awt.Rectangle)1 Dimension (org.openqa.selenium.Dimension)1