Selenium WebDriver - determine if element is clickable (i.e. not obscured by dojo modal lightbox) Selenium WebDriver - determine if element is clickable (i.e. not obscured by dojo modal lightbox) selenium selenium

Selenium WebDriver - determine if element is clickable (i.e. not obscured by dojo modal lightbox)


Use the WebDriverWait conditions.

    WebDriverWait wait = new WebDriverWait(yourWebDriver, 5);    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//xpath_to_element")));

Webdriver will wait for 5 seconds for your element to be able to be clicked.


You can use the ExpectedConditions.invisibilityOfElementLocated(By by) method which waits until the element is either invisible or not present on the DOM.

WebDriverWait wait = new WebDriverWait(yourWebDriver, 10);wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("yourSavingModalDialogDiv")));

So, depending on how much time your modal dialog takes to go invisible or go off the DOM, webdriver will wait. The wait is for a maximum of 10 seconds.


You could create a clickUntil function/method that does a WebDriver wait until the element is clickable with a timeout. It would attempt to click on the element, and throw away "Element is not clickable" error messages each time until it becomes clicked or times out.

Not sure how to write that in dojo, but that's an idea.