Methods
-
<async> checkImageInclusion(fullImage, includedImage [, opts])
-
Step to check one image includes or doesn't include another image.
Parameters:
Name Type Argument Description fullImage
string Path to image which may include.
includedImage
string Path to image which may be included.
opts
object <optional>
Step options.
Properties
Name Type Argument Default Description matchedDirPath
object <optional>
Folder path to save matched image.
threshold
number <optional>
0.05 Threshold of divergence.
shouldBe
boolean <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 actualImage
string Path to actual image.
expectedImage
string Path to expected image.
opts
object <optional>
Helper options.
Properties
Name Type Argument Default Description threshold
number <optional>
0.05 Threshold of divergence.
shouldBe
boolean <optional>
true Flag to check whether image are equal or not equal.
elements
Array.<string> <optional>
[] List of elements on image which should be verified.
diffDirPath
string <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 imageName
string Screenshot name. File extension
.png
will be added automatically.opts
object <optional>
Step options.
Properties
Name Type Argument Default Description imageDirPath
string <optional>
Screenshot folder path.
expectedDirPath
string <optional>
Expected screenshot path.
by
boolean <optional>
selenium Screenshot variant. Supported values are
selenium
,html2canvas
,system
.cssSelector
string <optional>
<nullable>
null C$ selector of DOM element which of screenshot should be made.
backColor
string <optional>
<nullable>
null Background color for html2canvas. Transparent by default.
preHook
function <optional>
<nullable>
null Function which will be called in
Steps
context in the beginning of step.postHook
function <optional>
<nullable>
null Function which will be called in
Steps
context at the end of step.elements
Array.<string> <optional>
[] List of elements on image which should be verified.
diffDirPath
string <optional>
Path to diffs folder.
check
boolean <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 opts
object <optional>
Step options.
Properties
Name Type Argument Default Description imageName
string <optional>
Screenshot name. File extension
.png
will be added automatically. Default value is dynamically generated on each call with algorithmuuid
.imageDirPath
string <optional>
Screenshot folder path.
by
boolean <optional>
Screenshot variant. Supported values are
selenium
,html2canvas
,system
. By defaultselenium
if browser is launched,system
otherwise.cssSelector
string <optional>
<nullable>
null CSS selector of DOM element which of screenshot should be made.
backColor
string <optional>
<nullable>
null Background color for html2canvas. Transparent by default.
preHook
function <optional>
<nullable>
null Function which will be called in
Steps
context in the beginning of step.postHook
function <optional>
<nullable>
null Function which will be called in
Steps
context at the end of step.element
string <optional>
<nullable>
null Web element name which should be screenshotted.
check
boolean <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 imgPath
string Path to resizing image.
percent
string <optional>
Percent to resize, for example
150%
.opts
object <optional>
Step options.
Properties
Name Type Argument Default Description width
string | number <optional>
Width of resized image in pixels or percent.
height
string | number <optional>
Height of resized image in pixels or percent.
check
boolean <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 });
-