public class SingltonBrowserImage extends Object
| Constructor and Description |
|---|
SingltonBrowserImage(Path el) |
| Modifier and Type | Method and Description |
|---|---|
void |
assertCanvasImageIsEqualToExpected(InputStream expectedImageInput)
Verify that the canvas image is pixel-perfect
|
void |
assertImageIsEqualToExpected(InputStream expectedImageInput)
Verify that the element's image is pixel-perfect
|
void |
assertImageIsEqualToExpectedWithShiftAndCrop(InputStream expectedImageInput,
int maxShift)
Verify that the element's image is pixel-perfect, but allowing one
to be a cropped/shifted version of the other.
|
void |
assertImageIsSimilarToExpected(InputStream expectedImageInput,
int maxBadPixelsRatio)
Verify the picture is "similar" to the reference image.
|
void |
assertImgSourceIsEqualToExpected(InputStream expectedImageInput)
Verify that the HTML img source is pixel-perfect
|
void |
captureCanvasToFile(File outputFile)
Capture the image of an HTML5 canvas as a png, and save it to the given file.
|
void |
captureImgSourceToFile(File outputFile)
Capture the source of an img element as a png, and save it to the given file
|
void |
captureToFile(File outputFile)
Capture the image of an element as a png, and save it to the given file
|
Optional<BufferedImage> |
getErrorImage(InputStream expectedImageInput)
compare captured image to a reference image and return an image that highlights the differences.
|
void |
show()
Display the element image in a separate window.
|
void |
showCanvas()
Similar to show(), but optimized for an HTML5 canvas element
|
public SingltonBrowserImage(Path el)
el - The element the represents the image we are interested inpublic void captureToFile(File outputFile)
outputFile - - output filepublic void captureImgSourceToFile(File outputFile)
outputFile - - output filepublic void captureCanvasToFile(File outputFile)
outputFile - - output filepublic void show()
public void showCanvas()
public void assertImageIsEqualToExpected(InputStream expectedImageInput) throws IOException
expectedImageInput - - reference png imageIOException - - file could not be readpublic void assertCanvasImageIsEqualToExpected(InputStream expectedImageInput) throws IOException
expectedImageInput - - reference png imageIOException - - file could not be readpublic void assertImgSourceIsEqualToExpected(InputStream expectedImageInput) throws IOException
expectedImageInput - - reference png imageIOException - - file could not be readpublic Optional<BufferedImage> getErrorImage(InputStream expectedImageInput) throws IOException
expectedImageInput - - reference png imageIOException - - file could not be readAssertionError - - images are not the same sizepublic void assertImageIsEqualToExpectedWithShiftAndCrop(InputStream expectedImageInput, int maxShift) throws IOException
expectedImageInput - - reference png imagemaxShift - maximum pixels the images are shifted/cropped compared to each otherIOException - - file could not be readpublic void assertImageIsSimilarToExpected(InputStream expectedImageInput, int maxBadPixelsRatio) throws IOException
expectedImageInput - - reference png imagemaxBadPixelsRatio - - a positive number. For example: If it's 100, then
1% of the pixels can have major differences compared to
the reference.IOException - - file could not be readCopyright © 2019. All rights reserved.