Skip to content

Commit 76fc459

Browse files
author
GuustMetz
committed
undo pressElement change
1 parent 5bf4637 commit 76fc459

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

test/public/defaults.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,25 @@ exports.waitForNavigation = waitForNavigation;
275275
* @returns {Promise} Whether the element was clickable or not.
276276
*/
277277
module.exports.pressElement = async (page, selector, jsClick = false) => {
278-
await page.waitForFunction( (sel) => !!document.querySelector(sel), {}, selector);
278+
await page.waitForFunction(
279+
(sel, isJsClick) => {
280+
const element = document.querySelector(sel);
281+
282+
if (!element) {
283+
return false;
284+
}
285+
286+
if (isJsClick) {
287+
element.click();
288+
}
289+
290+
return true;
291+
},
292+
{},
293+
selector, jsClick
294+
);
279295

280-
if (jsClick) {
281-
await page.evaluate((sel) => document.querySelector(sel).click(), selector);
282-
} else {
296+
if (!jsClick) {
283297
await page.click(selector);
284298
}
285299
};

0 commit comments

Comments
 (0)