Selenium - after bootstrap modal test, subsequent test fail with error ElementClickInterceptedError
You don't need to use the implicitwait everytime. What you need to wait for is the visibility of the elements before doing the click operations.
There is a elementIsVisible
method available in the wait condition. I've modified the code to check for the presence of the element and then the visibility of the element before doing the click.
(async function uitest() {
let driver = await new Builder().forBrowser('chrome').build();
let element
try {
await driver.get(fileName)
//Launch Modal 1 and close
await driver.findElement(By.id('launchModalButton')).click()
let closeButton1 = await driver.wait(until.elementLocated(By.id('closeButton')))
closeButton1 = await driver.wait(until.elementIsVisible(closeButton1))
await closeButton1.click()
// middle button click
await driver.findElement(By.id('button')).click()
//Launch Modal 2 and close
await driver.findElement(By.id('launchModalButton_2')).click()
let closeButton2 = await driver.wait(until.elementLocated(By.id('closeButton_2')))
closeButton2 = await driver.wait(until.elementIsVisible(closeButton2))
await closeButton2.click()
} catch (err) {
console.log(err)
} finally {
await driver.quit();
}
}
)()