Skip to content

Commit 3df6480

Browse files
tairunpuneet0191
authored andcommitted
Added conditional for WebDriver in 'screenshotElement' method. (#2)
1 parent 1961bc6 commit 3df6480

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,17 @@ class ResembleHelper extends Helper {
9494
await el.screenshot({
9595
path: configuration.screenshotFolder + name + '.png'
9696
});
97-
}
98-
else throw new Error("Method only works with Puppeteer");
97+
} else if (this.helpers['WebDriver']) {
98+
const configuration = this.config;
99+
100+
await helper.waitForVisible(selector);
101+
const els = await helper._locate(selector);
102+
if (!els.length) throw new Error(`Element ${selector} couldn't be located`);
103+
const el = els[0];
104+
105+
await el.saveScreenshot(configuration.screenshotFolder + name + '.png');
106+
}
107+
else throw new Error("Method only works with Puppeteer and WebDriver helpers.");
99108
}
100109

101110
/**

0 commit comments

Comments
 (0)