Images¶
-
public class
Images
¶
Methods¶
assertCanvasImageIsEqualToExpected¶
-
public static void
assertCanvasImageIsEqualToExpected
(InBrowser browser, Path el, InputStream expectedImageInput)¶ Verify that the element’s image is pixel-perfect
Parameters: - browser –
- browser
- el –
- canvas to capture and verify
- expectedImageInput – reference image file
Throws: - IOException –
- file could not be read
- browser –
assertHTMLImgSoureIsEqualToExpected¶
-
public static void
assertHTMLImgSoureIsEqualToExpected
(InBrowser browser, Path el, InputStream expectedImageInput)¶ Verify that an image downloaded from an HTML img src attribute, is pixel-perfect
Parameters: - browser –
- browser
- el –
- HTML img element to capture and verify
- expectedImageInput – reference image file
Throws: - IOException –
- file could not be read
- browser –
assertImageIsEqualToExpected¶
-
public static void
assertImageIsEqualToExpected
(InBrowser browser, Path el, InputStream expectedImageInput)¶ Verify that the element’s image is pixel-perfect
Parameters: - browser –
- browser
- el –
- element to capture and verify
- expectedImageInput – reference image file
Throws: - IOException –
- file could not be read
- browser –
assertImageIsEqualToExpectedWithShiftAndCrop¶
-
public static void
assertImageIsEqualToExpectedWithShiftAndCrop
(InBrowser browser, Path el, InputStream expectedImageInput, int maxShift)¶ Verify that the element’s image is pixel-perfect, but allowing some crop/shift
Parameters: - browser –
- browser
- el –
- element to capture and verify
- expectedImageInput – reference image file
- maxShift – maximum pixels the images are shifted/cropped compared to each other (both on x and y axis)
Throws: - IOException –
- file could not be read
- browser –
assertImageIsSimilarToExpected¶
-
public static void
assertImageIsSimilarToExpected
(InBrowser browser, Path el, InputStream expectedImageInput, int maxBadPixelsRatio)¶ Verify the picture is “similar” to the reference image. Ignores minor differences between the pixels.
Parameters: - browser –
- browser
- el –
- element to capture and validate
- expectedImageInput –
- reference image
- maxBadPixelsRatio –
- a positive number. For example: If it’s 100, then 1% of the pixels can have major differences compared to the reference.
Throws: - IOException –
- image file could not be read
- browser –
captureCanvas¶
-
public static BufferedImage
captureCanvas
(InBrowser browser, Path canvas)¶
captureCanvasToFile¶
captureImgSrcToFile¶
captureToFile¶
getErrorsImage¶
-
public static Optional<BufferedImage>
getErrorsImage
(InBrowser browser, Path el, InputStream expectedImageInput)¶ create and return an image that highlights the different pixels between the captured image and the reference image
Parameters: - browser –
- browser
- el –
- element to capture and verify
- expectedImageInput – reference image file
Throws: - IOException –
- file could not be read
- AssertionError –
- images are not the same size
Returns: an image that highlights the different pixels. If the images are equal, returns an empty optional.
- browser –
show¶
showCanvas¶
showImage¶
-
static void
showImage
(BufferedImage image)¶