Skip to content

Commit

Permalink
retry click a second time
Browse files Browse the repository at this point in the history
  • Loading branch information
campersau committed May 6, 2020
1 parent 67de641 commit 6d25051
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions clicktests/environment.js
Expand Up @@ -257,15 +257,17 @@ class Environment {
}

async click(selector) {
let elementHandle = await this.waitForElementVisible(selector);
try {
const elementHandle = await this.waitForElementVisible(selector);
if (elementHandle == null) {
throw new Error(`Element does not exist or is not visible: ${selector}`);
}
await elementHandle.click();
} catch (err) {
winston.error(`Failed to click element: ${selector}`);
throw err;
} catch (err1) {
elementHandle = await this.waitForElementVisible(selector);
try {
await elementHandle.click(); // try click a second time to reduce test flakiness
} catch (err2) {
winston.error(`Failed to click element: ${selector}`);
throw err2;
}
}
}

Expand Down

0 comments on commit 6d25051

Please sign in to comment.