Skip to content

Commit 030c5ce

Browse files
authored
Merge pull request #31 from Kartikeya99/ignoredBox
Ignored box
2 parents 845a018 + 06233f7 commit 030c5ce

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ It is exactly same as `seeVisualDiff` function, only an additional `selector` CS
7171

7272
Third one is the `screenshotElement` which basically takes screenshot of the element. Selector for the element must be provided.
7373
It saves the image in the output directory as mentioned in the config folder.
74-
This method only works with puppeteer.
7574
```js
7675
I.screenshotElement("selectorForElement", "nameForImage");
7776
```
77+
>Note: This method only works with puppeteer.
7878
7979
Finally to use the helper in your test, you can write something like this:
8080

@@ -102,6 +102,22 @@ Scenario('Compare CPU Usage Images', async (I) => {
102102
});
103103
```
104104

105+
### Ignored Box
106+
You can also exclude part of the image from comparison, by specifying the excluded area in pixels from the top left.
107+
Just declare an object and pass it options as `ignoredBox`:
108+
```
109+
const box = {
110+
left: 0,
111+
top: 10,
112+
right: 0,
113+
bottom: 10
114+
};
115+
116+
I.seeVisualDiff("image.png", {prepareBaseImage: true, tolerance: 1, ignoredBox: box});
117+
```
118+
After this, that specific mentioned part will be ignored while comparison.
119+
This works with both `seeVisualDiff` and `seeVisualDiffForElement`.
120+
105121
### Allure Reporter
106122
Allure reports may also be generated directly from the tool. To do so, add
107123
```

index.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class ResembleHelper extends Helper {
2626
image2 = this.config.screenshotFolder + image2;
2727

2828
return new Promise((resolve, reject) => {
29-
if (options.boundingBox !== undefined) {
30-
resemble.outputSettings({
31-
boundingBox: options.boundingBox
32-
});
33-
}
29+
30+
resemble.outputSettings({
31+
boundingBox: options.boundingBox,
32+
ignoredBox: options.ignoredBox
33+
});
3434

3535
this.debug("Tolerance Level Provided " + options.tolerance);
3636
const tolerance = options.tolerance;
@@ -48,6 +48,9 @@ class ResembleHelper extends Helper {
4848
if (err) {
4949
throw new Error(this.err);
5050
}
51+
else {
52+
this.debug(this.config.diffFolder + diffImage + '.png');
53+
}
5154
});
5255
}
5356
}

0 commit comments

Comments
 (0)