Skip to content

Commit 95b4591

Browse files
committed
Added check for puppeteer helper
1 parent 3dd89ee commit 95b4591

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

index.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,21 @@ class ResembleHelper extends Helper {
7575
* @returns {Promise<void}
7676
*/
7777
async screenshotElement(selector, name) {
78-
const helper = this._getHelper();
79-
const configuration = this.config;
78+
79+
if (this.helpers['Puppeteer']) {
80+
const helper = this._getHelper();
81+
const configuration = this.config;
8082

81-
await helper.waitForVisible(selector);
82-
const els = await helper._locate(selector);
83-
if (!els.length) throw new Error(`Element ${selector} couldn't be located`);
84-
const el = els[0];
83+
await helper.waitForVisible(selector);
84+
const els = await helper._locate(selector);
85+
if (!els.length) throw new Error(`Element ${selector} couldn't be located`);
86+
const el = els[0];
8587

86-
await el.screenshot({
87-
path: configuration.screenshotFolder + name + '.png'
88-
});
88+
await el.screenshot({
89+
path: configuration.screenshotFolder + name + '.png'
90+
});
91+
}
92+
else throw new Error("Method to be called only with Puppeteer. Other helpers not supported");
8993
}
9094

9195
/**

0 commit comments

Comments
 (0)