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
+20-19
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
@@ -27,21 +27,20 @@ Example:
27
27
}
28
28
}
29
29
```
30
+
30
31
To use the Helper, users must provide the three parameters:
31
32
32
-
`screenshotFolder` : This will always have the same value as `output` in Codecept configuration, this is the folder where webdriverIO
33
-
saves a screenshot when using `I.saveScreenshot` method
33
+
`screenshotFolder`: This will always have the same value as `output` in CodeceptJS configuration, this is the folder where WebdriverIO saves a screenshot when using `I.saveScreenshot` method.
34
34
35
-
`baseFolder`: This is the folder for base images, which will be used with screenshot for comparison
35
+
`baseFolder`: This is the folder for base images, which will be used with screenshot for comparison.
36
36
37
-
`diffFolder`: This will the folder where resemble would try to store the difference image, which can be viewed later,
37
+
`diffFolder`: This will the folder where resemble would try to store the difference image, which can be viewed later.
38
38
39
39
Usage, these are major functions that help in visual testing
40
40
41
41
First one is the `seeVisualDiff` which basically takes two parameters
42
-
1)`baseImage` Name of the base image, this will be the image used for comparison with the screenshot image,
43
-
it is mandatory to have the same image file names for base and screenshot image
44
-
2)`options` options can be passed which include `prepaseBaseImage` and `tolerance`
42
+
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.
43
+
2)`options` options can be passed which include `prepaseBaseImage` and `tolerance`.
45
44
46
45
```js
47
46
/**
@@ -52,7 +51,7 @@ it is mandatory to have the same image file names for base and screenshot image
52
51
*/
53
52
asyncseeVisualDiff(baseImage, options) {}
54
53
```
55
-
Second one is the `seeVisualDiffForElement` which basically compares elements on the screenshot, Selector for element must be provided
54
+
Second one is the `seeVisualDiffForElement` which basically compares elements on the screenshot, selector for element must be provided.
56
55
57
56
It is exactly same as `seeVisualDiff` function, only an additional `selector` CSS|XPath|ID locators is provided
58
57
```js
@@ -67,14 +66,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
69
+
`seeVisualDiffForElement` only works when the page for baseImage is open in the browser, so that WebdriverIO can fetch coordinates of the provided selector.
70
+
71
+
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.
71
72
72
-
Third one is the `screenshotElement` which basically takes screenshot of the element. Selector for the element must be provided.
73
-
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.
103
+
>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.
105
104
106
105
### Ignored Box
107
106
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.
120
-
This works with both`seeVisualDiff` and `seeVisualDiffForElement`.
119
+
This works for`seeVisualDiff` and `seeVisualDiffForElement`.
121
120
122
121
### Allure Reporter
123
122
Allure reports may also be generated directly from the tool. To do so, add
123
+
124
124
```
125
125
"plugins": {
126
126
"allure": {}
127
127
}
128
128
```
129
+
129
130
in the config file.
130
131
The attachments will be added to the report only when the calulated mismatch is greater than the given tolerance.
131
132
Set `output` to where the generated report is to be stored. Default is the output directory of the project.
@@ -155,8 +156,8 @@ When this option has been provided, the helper will download the base image from
155
156
This base image has to be located inside a folder named "*base*".
156
157
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.
157
158
If the `prepareBaseImage` option is marked `true`, then the generated base image will be uploaded to a folder named "*base*" in the S3 bucket.
158
-
>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.
159
+
>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.
159
160
160
161
### Known Issues:
161
162
162
-
> Issue in Windows where the image comparison is not carried out, and therefore no Mismatch Percentage is shown. See 'loadImageData' function in resemble.js
163
+
> Issue in Windows where the image comparison is not carried out, and therefore no Mismatch Percentage is shown. See 'loadImageData' function in resemble.js
0 commit comments