Skip to content

Correct typos #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# codeceptjs-resemblehelper
Helper for resemble.js, used for Image comparison in Tests with WebdriverIO
Helper for resemble.js, used for image comparison in tests with WebdriverIO.

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
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.

If two screenshot comparisons have difference greater then the tolerance provided, the test will fail.

NPM package: https://www.npmjs.com/package/codeceptjs-resemblehelper

To install the package, just run `npm install codeceptjs-resemblehelper`
To install the package, just run `npm install codeceptjs-resemblehelper`.

### Configuration

Expand All @@ -27,21 +27,20 @@ Example:
}
}
```

To use the Helper, users must provide the three parameters:

`screenshotFolder` : This will always have the same value as `output` in Codecept configuration, this is the folder where webdriverIO
saves a screenshot when using `I.saveScreenshot` method
`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.

`baseFolder`: This is the folder for base images, which will be used with screenshot for comparison
`baseFolder`: This is the folder for base images, which will be used with screenshot for comparison.

`diffFolder`: This will the folder where resemble would try to store the difference image, which can be viewed later,
`diffFolder`: This will the folder where resemble would try to store the difference image, which can be viewed later.

Usage, these are major functions that help in visual testing

First one is the `seeVisualDiff` which basically takes two parameters
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
2) `options` options can be passed which include `prepaseBaseImage` and `tolerance`
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.
2) `options` options can be passed which include `prepaseBaseImage` and `tolerance`.

```js
/**
Expand All @@ -52,7 +51,7 @@ it is mandatory to have the same image file names for base and screenshot image
*/
async seeVisualDiff(baseImage, options) {}
```
Second one is the `seeVisualDiffForElement` which basically compares elements on the screenshot, Selector for element must be provided
Second one is the `seeVisualDiffForElement` which basically compares elements on the screenshot, selector for element must be provided.

It is exactly same as `seeVisualDiff` function, only an additional `selector` CSS|XPath|ID locators is provided
```js
Expand All @@ -67,14 +66,14 @@ It is exactly same as `seeVisualDiff` function, only an additional `selector` CS
async seeVisualDiffForElement(selector, baseImage, options){}
```
> Note:
`seeVisualDiffForElement` only works when the page for baseImage is open in the browser, so that webdriver can fetch coordinates of the provided selector
`seeVisualDiffForElement` only works when the page for baseImage is open in the browser, so that WebdriverIO can fetch coordinates of the provided selector.

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.

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.
```js
I.screenshotElement("selectorForElement", "nameForImage");
```
>Note: This method only works with puppeteer.
> Note: This method only works with puppeteer.

Finally to use the helper in your test, you can write something like this:

Expand All @@ -101,7 +100,7 @@ Scenario('Compare CPU Usage Images', async (I) => {
I.seeVisualDiffForElement("//div[@class='panel-container']", "Complete_Dashboard_Image.png", {prepareBaseImage: false, tolerance: 3});
});
```
>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.
> 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.

### Ignored Box
You can also exclude part of the image from comparison, by specifying the excluded area in pixels from the top left.
Expand All @@ -117,15 +116,17 @@ const box = {
I.seeVisualDiff("image.png", {prepareBaseImage: true, tolerance: 1, ignoredBox: box});
```
After this, that specific mentioned part will be ignored while comparison.
This works with both `seeVisualDiff` and `seeVisualDiffForElement`.
This works for `seeVisualDiff` and `seeVisualDiffForElement`.

### Allure Reporter
Allure reports may also be generated directly from the tool. To do so, add

```
"plugins": {
"allure": {}
}
```

in the config file.
The attachments will be added to the report only when the calulated mismatch is greater than the given tolerance.
Set `output` to where the generated report is to be stored. Default is the output directory of the project.
Expand Down Expand Up @@ -155,8 +156,8 @@ When this option has been provided, the helper will download the base image from
This base image has to be located inside a folder named "*base*".
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.
If the `prepareBaseImage` option is marked `true`, then the generated base image will be uploaded to a folder named "*base*" in the S3 bucket.
>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.
> 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.

### Known Issues:

> Issue in Windows where the image comparison is not carried out, and therefore no Mismatch Percentage is shown. See 'loadImageData' function in resemble.js
> Issue in Windows where the image comparison is not carried out, and therefore no Mismatch Percentage is shown. See 'loadImageData' function in resemble.js