public class Images extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Images.ImageComparator
Internal utility class for images
|
static class |
Images.Obscure |
| Constructor and Description |
|---|
Images() |
| Modifier and Type | Method and Description |
|---|---|
static void |
assertCanvasImageIsEqualToExpected(InBrowser browser,
Path el,
InputStream expectedImageInput)
Verify that the element's image is pixel-perfect
|
static void |
assertHTMLImgSoureIsEqualToExpected(InBrowser browser,
Path el,
InputStream expectedImageInput)
Verify that an image downloaded from an HTML img src attribute, is pixel-perfect
|
static void |
assertImageIsEqualToExpected(InBrowser browser,
Path el,
InputStream expectedImageInput)
Verify that the element's image is pixel-perfect
|
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
|
static void |
assertImageIsSimilarToExpected(InBrowser browser,
Path el,
InputStream expectedImageInput,
int maxBadPixelsRatio)
Verify the picture is "similar" to the reference image.
|
static BufferedImage |
captureCanvas(InBrowser browser,
Path canvas) |
static void |
captureCanvasToFile(InBrowser browser,
Path el,
File outputFile)
Save an HTML5 canvas to file.
|
static void |
captureImgSrcToFile(InBrowser browser,
Path imgEl,
File outputFile)
Save the source of an HTML img element to file
|
static void |
captureToFile(InBrowser browser,
Path el,
File outputFile)
Save image to file
|
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
|
static void |
show(InBrowser browser,
Path el)
Display image of an element in a separate window.
|
static void |
showCanvas(InBrowser browser,
Path el)
Display image of an HTML5 canvas element in a separate window.
|
public static void captureToFile(InBrowser browser, Path el, File outputFile)
browser - - browserel - - Path element to captureoutputFile - - output filepublic static void captureCanvasToFile(InBrowser browser, Path el, File outputFile)
browser - - browserel - - Path element to captureoutputFile - - output filepublic static void captureImgSrcToFile(InBrowser browser, Path imgEl, File outputFile)
browser - - browserimgEl - - HTML img element to captureoutputFile - - output filepublic static void show(InBrowser browser, Path el)
browser - - browserel - - the element to capture and displaypublic static void showCanvas(InBrowser browser, Path el)
browser - - browserel - - the element to capture and displaypublic static void assertHTMLImgSoureIsEqualToExpected(InBrowser browser, Path el, InputStream expectedImageInput) throws IOException
browser - - browserel - - HTML img element to capture and verifyexpectedImageInput - reference image fileIOException - - file could not be readpublic static void assertImageIsEqualToExpected(InBrowser browser, Path el, InputStream expectedImageInput) throws IOException
browser - - browserel - - element to capture and verifyexpectedImageInput - reference image fileIOException - - file could not be readpublic static void assertCanvasImageIsEqualToExpected(InBrowser browser, Path el, InputStream expectedImageInput) throws IOException
browser - - browserel - - canvas to capture and verifyexpectedImageInput - reference image fileIOException - - file could not be readpublic static Optional<BufferedImage> getErrorsImage(InBrowser browser, Path el, InputStream expectedImageInput) throws IOException
browser - - browserel - - element to capture and verifyexpectedImageInput - reference image fileIOException - - file could not be readAssertionError - - images are not the same sizepublic static void assertImageIsEqualToExpectedWithShiftAndCrop(InBrowser browser, Path el, InputStream expectedImageInput, int maxShift) throws IOException
browser - - browserel - - element to capture and verifyexpectedImageInput - reference image filemaxShift - maximum pixels the images are shifted/cropped compared to each other (both on x and y axis)IOException - - file could not be readpublic static void assertImageIsSimilarToExpected(InBrowser browser, Path el, InputStream expectedImageInput, int maxBadPixelsRatio) throws IOException
browser - - browserel - - element to capture and validateexpectedImageInput - - reference imagemaxBadPixelsRatio - - a positive number. For example: If it's 100, then
1% of the pixels can have major differences compared to
the reference.IOException - - image file could not be readpublic static BufferedImage captureCanvas(InBrowser browser, Path canvas)
Copyright © 2019. All rights reserved.