use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.
the class HtmlElement method detectViewPortPosition.
private Rectangle detectViewPortPosition() {
BufferedImage image;
try {
image = ImageProcessor.loadFromFile(getViewportScreenshotFile());
BufferedImage croppedImage = ImageProcessor.cropImage(image, 0, 0, image.getWidth(), 150);
File cropScreenshotFile = File.createTempFile("img", ".png");
ImageIO.write(croppedImage, "png", cropScreenshotFile);
File desktopScreenshotFile = getDesktopScreenshotFile();
if (desktopScreenshotFile == null) {
throw new ScreenshotException("Desktop screenshot does not exist");
}
ImageDetector imageDetector = new ImageDetector(desktopScreenshotFile, cropScreenshotFile, 0.2);
imageDetector.detectExactZoneWithoutScale();
org.openqa.selenium.Rectangle detectedRectangle = imageDetector.getDetectedRectangle();
return new Rectangle(detectedRectangle.x, detectedRectangle.y, detectedRectangle.height, detectedRectangle.width);
} catch (IOException e) {
throw new ScreenshotException("Error getting position of viewport: " + e.getMessage());
}
}
use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.
the class TestImageDetector method searchPictureWith180degRotation.
/**
* Search an image inside an other one, 180° rotation, no resizing
* @throws IOException
*/
@Test(groups = { "ut" }, enabled = false)
public void searchPictureWith180degRotation() throws IOException {
ImageDetector detector = new ImageDetector(createFileFromResource("tu/images/p9.png"), createFileFromResource("tu/images/vosAlertesRotate180.png"));
detector.detectCorrespondingZone();
Assert.assertEquals(detector.getRotationAngle(), 180);
Assert.assertEquals(detector.getDetectedRectangle(), new Rectangle(574, 135, 29, 107));
}
use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.
the class TestImageDetector method searchPicturesByTemplate.
/**
* Search an image inside an other with templace matching
* @throws IOException
*/
// low resolution
@Test(groups = { "ut" })
public void searchPicturesByTemplate() throws IOException {
ImageDetector detector = new ImageDetector(createFileFromResource("tu/images/infolidays.png"), createFileFromResource("tu/images/bouton_enregistrer.png"), 0.06);
detector.detectExactZoneWithScale();
Assert.assertEquals(detector.getDetectedRectangle(), new Rectangle(457, 1582, 232, 487));
Assert.assertEquals(detector.getSizeRatio(), 2.5, 0.05);
}
use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.
the class TestImageDetector method searchPictureWithResizing.
/**
* Search an image inside an other one, 0° rotation, 80% resizing
* @throws IOException
*/
@Test(groups = { "ut" }, enabled = false)
public void searchPictureWithResizing() throws IOException {
ImageDetector detector = new ImageDetector(createFileFromResource("tu/images/RIB.png"), createFileFromResource("tu/images/creditMutuelLogo0.8.png"));
detector.detectCorrespondingZone();
Assert.assertEquals(detector.getRotationAngle(), 0);
Assert.assertEquals(detector.getDetectedRectangle(), new Rectangle(603, 147, 77, 493));
}
use of com.seleniumtests.util.imaging.ImageDetector in project seleniumRobot by bhecquet.
the class TestImageDetector method searchPictureWith90degRotation.
/**
* Search an image inside an other one, 90° rotation, no resizing
* @throws IOException
*/
@Test(groups = { "ut" }, enabled = false)
public void searchPictureWith90degRotation() throws IOException {
ImageDetector detector = new ImageDetector(createFileFromResource("tu/images/p9.png"), createFileFromResource("tu/images/vosAlertesRotate90.png"));
detector.detectCorrespondingZone();
Assert.assertEquals(detector.getRotationAngle(), 90);
Assert.assertEquals(detector.getDetectedRectangle(), new Rectangle(574, 136, 29, 107));
}
Aggregations