Hi folks,

   Could anyone please tell me how to check whether the element is clickable or not?

I want to iterate till the button is clickable.

Kind Regards,


Views: 189

Reply to This

Replies to This Discussion

Would using .enabled? work?

Hi Eric,

   I tried using enabled() , but it doesn't stop at the last page. Means its iterating  the last page without exiting the loop. Is that anything to do with click?

I'm not sure. I guess at this point I would do some tests to make sure things are OK.

One test I would do is to verify you can click the button just doing a simple time-based delay. Let's say for example that the button you are waiting to click takes 5-10 seconds to become clickable. I would put in a sleep statement for 30 seconds and then try clicking on the button. You wouldn't want to do that in your actual test automation, but it would at least tell you whether or not you have the correct locator.

Another test I would do is to check to see if using enabled() ever gives you the expected answer. I would do a loop for a period of time longer than it normally takes the button to become clickable. In that loop I would print out the value of enabled(). Hopefully we would see it print out false several times and then switch to true.

Here's an example in Ruby:

require 'selenium-webdriver'

def launch_browser(url)
  driver = Selenium::WebDriver.for(:firefox, marionette: true)
  wait = Selenium::WebDriver::Wait.new(:timeout => 10)
  driver.get url
  return driver, wait

test_url = "https://www.google.com/advanced_search"

driver, wait = launch_browser(test_url)

advanced_search_button = driver.find_element(:css, "body > div.bottom-wrapper > div._Vkb > form > div:nth-child(5) > div:nth-child(9) > div._Ai > input")

for i in 1..15
  puts "Is it enabled: #{advanced_search_button.enabled?}"
  sleep 1


Not the best example since the Advanced Search button is enabled from the very start on this page, but I couldn't think of any examples where controls were only enabled after a delay.

Anyway, I think these tests would tell you if using enabled() is giving you the expected results on the state of the button's clickability.

Hi Eric,

 Its working fine now. Thank you for your valuable time.

Have you tried using element_to_be_clickable?

Refer from Expected Conditions section in the Explicit Waits API doc:

Hi Joyz,

   Yes, i sorted it with explicit timeout. Thank you for your valuable response.



© 2017   Created by Rosie Sherry.   Powered by

Badges  |  Report an Issue  |  Terms of Service