I'm struggling to detect the absence of an element using the elementIsNotVisible
condition in the Selenium JavaScript Webdriver. This condition requires a webdriver.WebElement object, which is problematic because the element may have already disappeared from the page, leading to a NoSuchElementException
. Using driver.findElement()
won't work either as it returns a WebElementPromise
object.
driver.wait(until.elementIsNotVisible(driver.findElement(By.css('div.bg-danger > div'))));
var element = driver.findElement(By.css('div.bg-danger > div')); // WebElement
driver.wait(until.elementIsNotVisible(element)); // not a WebElementPromise
How can I overcome this frustrating issue?