diff --git a/test/e2e/webdriver/driver.js b/test/e2e/webdriver/driver.js index 117a783ecd3e..d938999b6ef0 100644 --- a/test/e2e/webdriver/driver.js +++ b/test/e2e/webdriver/driver.js @@ -390,9 +390,23 @@ class Driver { return elements.map((element) => wrapElementWithAPI(element, this)); } - async clickElement(rawLocator) { - const element = await this.findClickableElement(rawLocator); - await element.click(); + async clickElement(rawLocator, retries = 3) { + for (let attempt = 0; attempt < retries; attempt++) { + try { + const element = await this.findClickableElement(rawLocator); + await element.click(); + return; + } catch (error) { + if ( + error.name === 'StaleElementReferenceError' && + attempt < retries - 1 + ) { + await this.driver.delay(1000); + } else { + throw error; + } + } + } } /**