Wait for an element to be accessible using Selenium WebDriver

0 votes

I am automating a web application. I found that some commands bring up dialog boxes that have controls that are visible, but not accessible.

How to wait for the element to be actually accessible, and not just visible?

Below is the code that I tried, but it is not working out for me:

    try:
        print "wait for the element"
        element = WebDriverWait(driver, 10).until(lambda driver : driver.find_element_by_id("Btn_1"))
        print "not found!"
    finally: print 'yoo'

May 18, 2018 in Selenium by Meci Matt
• 9,400 points
86 views

1 answer to this question.

0 votes

You can try out the below code:

    print time.time()
    try:
        print "wait for the element"
        def find(driver):
            web = driver.find_element_by_id("Btn_1")
            if (web.get_attribute("disabled")=='true'):
                return False
            return web
        element = WebDriverWait(driver, 10).until(find)
        print "not found!"
    finally: print 'yoo'
    print "ok"
    print time.time()

answered May 18, 2018 by Atul
• 10,240 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to apply wait for new window using Selenium WebDriver?

As sometimes during web automation, when you ...READ MORE

answered Jul 9 in Selenium by Vaishali Walia
47 views
0 votes
1 answer

Locating an element by value using css selector using Selenium WebDriver

Below code will help By.cssSelector("td[class='someclass'][value='u ...READ MORE

answered Apr 9, 2018 in Selenium by coldcode
• 2,010 points
84 views
0 votes
1 answer

Using gettext() method for the specific element using Selenium WebDriver

Mistake is that u r printing the ...READ MORE

answered Apr 10, 2018 in Selenium by Vardy
• 2,280 points
3,895 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
260 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
629 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
257 views