You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-16
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
# codeceptjs-resemblehelper
2
-
Helper for resemble.js, used for Image comparison in Tests with WebdriverIO
2
+
Helper for resemble.js, used for image comparison in tests with WebdriverIO.
3
3
4
-
codeceptjs-resemblehelper is [CodeceptJS](https://codecept.io/) helper which can be used to compare screenshots and make the tests fail/pass based on the tolerance allowed
4
+
codeceptjs-resemblehelper is a [CodeceptJS](https://codecept.io/) helper which can be used to compare screenshots and make the tests fail/pass based on the tolerance allowed.
5
5
6
6
If two screenshot comparisons have difference greater then the tolerance provided, the test will fail.
To install the package, just run `npm install codeceptjs-resemblehelper`
10
+
To install the package, just run `npm install codeceptjs-resemblehelper`.
11
11
12
12
### Configuration
13
13
@@ -26,18 +26,18 @@ Example:
26
26
}
27
27
}
28
28
```
29
+
29
30
To use the Helper, users must provide the two parameters:
30
31
31
-
`baseFolder`: This is the folder for base images, which will be used with screenshot for comparison
32
+
`baseFolder`: This is the folder for base images, which will be used with screenshot for comparison.
32
33
33
34
`diffFolder`: This will the folder where resemble would try to store the difference image, which can be viewed later.
34
35
35
36
Usage, these are major functions that help in visual testing
36
37
37
38
First one is the `seeVisualDiff` which basically takes two parameters
38
-
1)`baseImage` Name of the base image, this will be the image used for comparison with the screenshot image,
39
-
it is mandatory to have the same image file names for base and screenshot image
40
-
2)`options` options can be passed which include `prepaseBaseImage` and `tolerance`
39
+
1)`baseImage` Name of the base image, this will be the image used for comparison with the screenshot image. It is mandatory to have the same image file names for base and screenshot image.
40
+
2)`options` options can be passed which include `prepaseBaseImage` and `tolerance`.
41
41
42
42
```js
43
43
/**
@@ -48,7 +48,7 @@ it is mandatory to have the same image file names for base and screenshot image
48
48
*/
49
49
asyncseeVisualDiff(baseImage, options) {}
50
50
```
51
-
Second one is the `seeVisualDiffForElement` which basically compares elements on the screenshot, Selector for element must be provided
51
+
Second one is the `seeVisualDiffForElement` which basically compares elements on the screenshot, selector for element must be provided.
52
52
53
53
It is exactly same as `seeVisualDiff` function, only an additional `selector` CSS|XPath|ID locators is provided
54
54
```js
@@ -63,14 +63,14 @@ It is exactly same as `seeVisualDiff` function, only an additional `selector` CS
`seeVisualDiffForElement` only works when the page for baseImage is open in the browser, so that webdriver can fetch coordinates of the provided selector
66
+
`seeVisualDiffForElement` only works when the page for baseImage is open in the browser, so that WebdriverIO can fetch coordinates of the provided selector.
67
+
68
+
Third one is the `screenshotElement` which basically takes screenshot of the element. Selector for the element must be provided. It saves the image in the output directory as mentioned in the config folder.
67
69
68
-
Third one is the `screenshotElement` which basically takes screenshot of the element. Selector for the element must be provided.
69
-
It saves the image in the output directory as mentioned in the config folder.
>Note: `seeVisualDiff` and `seeVisualDiffElement` work only when the dimensions of the screenshot as well as the base image are same so as to avoid unexpected results.
100
+
>Note: `seeVisualDiff` and `seeVisualDiffElement` work only when the dimensions of the screenshot as well as the base image are same so as to avoid unexpected results.
101
101
102
102
### Ignored Box
103
103
You can also exclude part of the image from comparison, by specifying the excluded area in pixels from the top left.
After this, that specific mentioned part will be ignored while comparison.
116
-
This works with both`seeVisualDiff` and `seeVisualDiffForElement`.
116
+
This works for`seeVisualDiff` and `seeVisualDiffForElement`.
117
117
118
118
### Allure Reporter
119
119
Allure reports may also be generated directly from the tool. To do so, add
120
+
120
121
```
121
122
"plugins": {
122
123
"allure": {}
123
124
}
124
125
```
126
+
125
127
in the config file.
126
128
The attachments will be added to the report only when the calulated mismatch is greater than the given tolerance.
127
129
Set `output` to where the generated report is to be stored. Default is the output directory of the project.
@@ -150,8 +152,8 @@ When this option has been provided, the helper will download the base image from
150
152
This base image has to be located inside a folder named "*base*".
151
153
The resultant output image will be uploaded in a folder named "*output*" and diff image will be uploaded to a folder named "*diff*" in the S3 bucket.
152
154
If the `prepareBaseImage` option is marked `true`, then the generated base image will be uploaded to a folder named "*base*" in the S3 bucket.
153
-
>Note: The tests may take a bit longer to run when the AWS configuration is provided as determined by the internet speed to upload/download images.
155
+
>Note: The tests may take a bit longer to run when the AWS configuration is provided as determined by the internet speed to upload/download images.
154
156
155
157
### Known Issues:
156
158
157
-
> Issue in Windows where the image comparison is not carried out, and therefore no Mismatch Percentage is shown. See 'loadImageData' function in resemble.js
159
+
> Issue in Windows where the image comparison is not carried out, and therefore no Mismatch Percentage is shown. See 'loadImageData' function in resemble.js
`${image2}${err.code==='ENOENT' ? 'screenshot image does not exist' : 'is read-only'}`);
40
+
}
41
+
});
28
42
29
43
returnnewPromise((resolve,reject)=>{
30
44
@@ -40,7 +54,7 @@ class ResembleHelper extends Helper {
40
54
if(err){
41
55
reject(err);
42
56
}else{
43
-
if(!data.isSameDimensions)thrownewError("The images are not of same dimensions. Please use images of same dimensions so as to avoid any unexpected results.")
57
+
if(!data.isSameDimensions)reject(newError("The images are not of same dimensions. Please use images of same dimensions so as to avoid any unexpected results."));
0 commit comments