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,460 points
609 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
2 answers
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, 2019 in Selenium by Vaishali Walia
4,894 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=' ...READ MORE

answered Apr 9, 2018 in Selenium by coldcode
• 2,070 points
691 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,360 points
26,242 views
0 votes
2 answers

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,520 points
5,630 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,100 points
6,203 views
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,890 points
3,855 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,100 points
4,760 views