Handle errors for unclickable buttons in the clickButtonWithText function

This commit is contained in:
Kevin MacMartin 2021-01-04 19:48:11 -05:00
parent 2893d9fe28
commit 080e5a611d

View file

@ -11,8 +11,12 @@ async function clickButtonWithText(page, text) {
const [ button ] = await page.$x(`//button[contains(., '${text}')]`); const [ button ] = await page.$x(`//button[contains(., '${text}')]`);
if (typeof button !== "undefined") { if (typeof button !== "undefined") {
try {
await button.click(); await button.click();
return true; return true;
} catch (err) {
return false;
}
} else { } else {
return false; return false;
} }