I'm having an issue where Selenium is saying a button is clickable even, when it's disabled.

I'm using Selenium with a website, where you have to select a date 1st and then time slot from a drop-down list before the Book button is clickable and will actually do anything. Before the date and time slot are chosen, the button element is

 <div id="pt1:b2" class="x28o xfn p_AFDisabled p_AFTextOnly" style="width:300px;" _afrgrp="0" role="presentation"><a data-afr-fcs="false" class="xfp" aria-disabled="true" role="button"><span class="xfx">Book</span></a></div>

After the date and time slot are chosen, the button becomes:

<div id="pt1:b2" class="x28o xfn p_AFTextOnly" style="width:300px;" _afrgrp="0" role="presentation"><a href="#" onclick="this.focus();return false" data-afr-fcs="true" class="xfp" role="button"><span class="xfx">Book</span></a></div>

I'm trying to use this code to wait for the button to be clickable

    wait = WebDriverWait(driver, 10)
    wait.until(EC.element_to_be_clickable((By.ID, 'pt1:b2')))

But Selenium is saying the button is clickable almost immediately upon the website loading even without a date or time slot chosen and the button being completely greyed out and unclickable.

I've tested this by checking the timestamps from after navigating to the URL and after waiting for the button to be clickable, and there's almost no delay. I've manually resorted to a try except loop and sleeping in between to be able to click the button successfully, but would rather figure out what's causing this issue.

1 Answer 1


Your HTML code doesn't contain disabled attribute to disable the field its being disabled by the class name x28o xfn p_AFDisabled p_AFTextOnly when it is enabled classname changes to x28o xfn p_AFTextOnly

Probably you should validate with the class name instead of using elementisclickable

Try this below

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div[class='x28o xfn p_AFTextOnly']")))


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.