Handle errors for unclickable buttons in the clickButtonWithText function
This commit is contained in:
parent
2893d9fe28
commit
080e5a611d
1 changed files with 6 additions and 2 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue