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
1 changed files with 6 additions and 2 deletions

View File

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