Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium ExpectedConditions NOT elementToBeClickable

Tags:

java

selenium

Working in Java, with an entry-level knowledge. We are in the process of moving to Selenium 3, and I was told WebDriverWait needs to use ExpectedConditions, using other methods could lead to having to redo it after the upgrade. Not sure about this, but I'm going to follow orders here.

I'm trying to get rid of a hard wait in an automation spec. I'm trying to setup a wait to make sure an element becomes unclickable. More or less trying to do the opposite of

WebDriverWait(driver, Timeout.SHORT)
    .until(ExpectedConditions.elementToBeClickable(By.id(elementID)));

There was a single post on SO that referenced this. I tried to implement their answer, but alas it did not work. That answer can be found here: How to wait for an element NOT to be clickable using Selenium Webdriver?

I was getting some errors on top of some issues related to the use of Predicate class.

Any and all help/suggestions would be greatly appreciated.

like image 218
TheDubiousDubber Avatar asked Dec 13 '25 13:12

TheDubiousDubber


1 Answers

The ExpectedConditions of Selenium come with ExpectedConditions.not() which should be exactly what you are asking for (link to documentation).

WebDriverWait(driver, Timeout.SHORT)
    .until(ExpectedConditions.not(
        ExpectedConditions.elementToBeClickable(By.id(elementID)))
    );
like image 200
Abaddon666 Avatar answered Dec 15 '25 01:12

Abaddon666



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!