Methods
-
<async> checkImageInclusion(fullImage, includedImage [, opts])
-
Step to check one image includes or doesn't include another image.
Parameters:
Name Type Argument Description fullImagestring Path to image which may include.
includedImagestring Path to image which may be included.
optsobject <optional>
Step options.
Properties
Name Type Argument Default Description matchedDirPathobject <optional>
Folder path to save matched image.
thresholdnumber <optional>
0.05 Threshold of divergence.
shouldBeboolean <optional>
true Flag to check whether image are equal or not equal.
Throws:
-
If result of images inclusion doesn't pass requested parameters.
- Type
- AssertionError
Returns:
- Type
- Promise.<void>
Example
await $.checkImageInclusion("./full.png", "./part.png"); await $.checkImageInclusion("./full.png", "./part.png", { shouldBe: false }); -
-
<async> checkImagesEquivalence(actualImage, expectedImage [, opts])
-
Step to check whether two image are equal or not equal.
Parameters:
Name Type Argument Description actualImagestring Path to actual image.
expectedImagestring Path to expected image.
optsobject <optional>
Helper options.
Properties
Name Type Argument Default Description thresholdnumber <optional>
0.05 Threshold of divergence.
shouldBeboolean <optional>
true Flag to check whether image are equal or not equal.
elementsArray.<string> <optional>
[] List of elements on image which should be verified.
diffDirPathstring <optional>
Path to diffs folder.
Throws:
-
If result of images comparison doesn't pass requested parameters.
- Type
- AssertionError
Returns:
- Type
- Promise.<void>
Example
await $.checkImagesEquivalence("./actual.png", "./expected.png"); await $.checkImagesEquivalence("./actual.png", "./expected.png", { shouldBe: false }); -
-
<async> checkOrMakeScreenshot(imageName [, opts])
-
Step to check or make screenshot of browser or display.
Parameters:
Name Type Argument Description imageNamestring Screenshot name. File extension
.pngwill be added automatically.optsobject <optional>
Step options.
Properties
Name Type Argument Default Description imageDirPathstring <optional>
Screenshot folder path.
expectedDirPathstring <optional>
Expected screenshot path.
byboolean <optional>
selenium Screenshot variant. Supported values are
selenium,html2canvas,system.cssSelectorstring <optional>
<nullable>
null C$ selector of DOM element which of screenshot should be made.
backColorstring <optional>
<nullable>
null Background color for html2canvas. Transparent by default.
preHookfunction <optional>
<nullable>
null Function which will be called in
Stepscontext in the beginning of step.postHookfunction <optional>
<nullable>
null Function which will be called in
Stepscontext at the end of step.elementsArray.<string> <optional>
[] List of elements on image which should be verified.
diffDirPathstring <optional>
Path to diffs folder.
checkboolean <optional>
true Flag to check screenshot is saved or no.
Throws:
-
If screenshot isn't saved.
- Type
- AssertionError
Returns:
- Type
- Promise.<void>
Example
await $.checkOrMakeScreenshot("my image"); await $.checkOrMakeScreenshot("my image", { by: "html2canvas" }); -
-
<async> makeScreenshot( [opts])
-
Step to make screenshot of browser or display.
Parameters:
Name Type Argument Description optsobject <optional>
Step options.
Properties
Name Type Argument Default Description imageNamestring <optional>
Screenshot name. File extension
.pngwill be added automatically. Default value is dynamically generated on each call with algorithmuuid.imageDirPathstring <optional>
Screenshot folder path.
byboolean <optional>
Screenshot variant. Supported values are
selenium,html2canvas,system. By defaultseleniumif browser is launched,systemotherwise.cssSelectorstring <optional>
<nullable>
null CSS selector of DOM element which of screenshot should be made.
backColorstring <optional>
<nullable>
null Background color for html2canvas. Transparent by default.
preHookfunction <optional>
<nullable>
null Function which will be called in
Stepscontext in the beginning of step.postHookfunction <optional>
<nullable>
null Function which will be called in
Stepscontext at the end of step.elementstring <optional>
<nullable>
null Web element name which should be screenshotted.
checkboolean <optional>
true Flag to check screenshot is saved or no.
Throws:
-
If screenshot isn't saved.
- Type
- AssertionError
Returns:
Path to saved screenshot.
- Type
- Promise.<string>
Example
await $.makeScreenshot(); // saves screenshot with generated file name await $.makeScreenshot({ imageName: "my image" }); // saves screenshot with custom name await $.makeScreenshot({ imageName: "my image", element: "searchButton" }); -
-
<async> resizeImage(imgPath [, percent] [, opts])
-
Step to resize image.
Parameters:
Name Type Argument Description imgPathstring Path to resizing image.
percentstring <optional>
Percent to resize, for example
150%.optsobject <optional>
Step options.
Properties
Name Type Argument Default Description widthstring | number <optional>
Width of resized image in pixels or percent.
heightstring | number <optional>
Height of resized image in pixels or percent.
checkboolean <optional>
true Check that image is resized.
Throws:
-
-
If image path doesn't exist.
- Type
- AssertionError
-
-
-
If image can't be resized.
- Type
- AssertionError
-
Returns:
- Type
- Promise
Example
await $.resizeImage(imgPath, "75%"); await $.resizeImage(imgPath, { width: "150%", height: "125%" }); await $.resizeImage(imgPath, { width: 800, height: 600 }); -