Skip to content

Commit

Permalink
Added check for puppeteer helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartikeya99 committed Jun 1, 2019
1 parent 3dd89ee commit 95b4591
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions index.js
Expand Up @@ -75,17 +75,21 @@ class ResembleHelper extends Helper {
* @returns {Promise<void}
*/
async screenshotElement(selector, name) {
const helper = this._getHelper();
const configuration = this.config;

if (this.helpers['Puppeteer']) {
const helper = this._getHelper();
const configuration = this.config;

await helper.waitForVisible(selector);
const els = await helper._locate(selector);
if (!els.length) throw new Error(`Element ${selector} couldn't be located`);
const el = els[0];
await helper.waitForVisible(selector);
const els = await helper._locate(selector);
if (!els.length) throw new Error(`Element ${selector} couldn't be located`);
const el = els[0];

await el.screenshot({
path: configuration.screenshotFolder + name + '.png'
});
await el.screenshot({
path: configuration.screenshotFolder + name + '.png'
});
}
else throw new Error("Method to be called only with Puppeteer. Other helpers not supported");
}

/**
Expand Down

0 comments on commit 95b4591

Please sign in to comment.