Skip to content

Commit a878ef7

Browse files
authored
Merge pull request #39 from Kartikeya99/screenshotFolder
screenshotFolder paramter
2 parents 5181f41 + 68a656b commit a878ef7

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

Diff for: README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ Example:
2020
"helpers": {
2121
"ResembleHelper" : {
2222
"require": "codeceptjs-resemblehelper",
23-
"screenshotFolder" : "./tests/output/",
2423
"baseFolder": "./tests/screenshots/base/",
2524
"diffFolder": "./tests/screenshots/diff/"
2625
}
2726
}
2827
}
2928
```
3029

31-
To use the Helper, users must provide the three parameters:
32-
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.
30+
To use the Helper, users must provide the two parameters:
3431

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

@@ -139,7 +136,6 @@ It can be used by adding the *aws* code inside `"ResembleHelper"` in the `"helpe
139136
"helpers": {
140137
"ResembleHelper" : {
141138
"require": "codeceptjs-resemblehelper",
142-
"screenshotFolder" : "<location of output folder>",
143139
"baseFolder": "<location of base folder>",
144140
"diffFolder": "<location of diff folder>",
145141
"aws": {

Diff for: index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,13 @@ class ResembleHelper extends Helper {
9797
async screenshotElement(selector, name) {
9898
const helper = this._getHelper();
9999
if(this.helpers['Puppeteer']){
100-
const configuration = this.config;
101-
102100
await helper.waitForVisible(selector);
103101
const els = await helper._locate(selector);
104102
if (!els.length) throw new Error(`Element ${selector} couldn't be located`);
105103
const el = els[0];
106104

107105
await el.screenshot({
108-
path: configuration.screenshotFolder + name + '.png'
106+
path: global.output_dir + "/" + name + '.png'
109107
});
110108
} else if (this.helpers['WebDriver']) {
111109
const configuration = this.config;
@@ -252,6 +250,7 @@ class ResembleHelper extends Helper {
252250
}
253251

254252
const awsC = this.config.aws;
253+
this.config.screenshotFolder = global.output_dir + "/";
255254

256255
if (awsC !== undefined && options.prepareBaseImage === false) {
257256
await this._download(awsC.accessKeyId, awsC.secretAccessKey, awsC.region, awsC.bucketName, baseImage);
@@ -290,6 +289,7 @@ class ResembleHelper extends Helper {
290289
}
291290

292291
const awsC = this.config.aws;
292+
this.config.screenshotFolder = global.output_dir + "/";
293293

294294
if (awsC !== undefined && options.prepareBaseImage === false) {
295295
await this._download(awsC.accessKeyId, awsC.secretAccessKey, awsC.region, awsC.bucketName, baseImage);

0 commit comments

Comments
 (0)