1

There's a button on the webpage that looks like this:

<button class="WAXG WEXG WKKH WOWG WPO" tabindex="0" data-automation-activebutton="true" aria-hidden="false" aria-disabled="false" data-automation-id="wd-ActiveList-addButton" role="button" data-automation-button-type="AUXILIARY" title="Add" type="button"><span class="WFXG WBXG"></span><span class="WCXG" title="Add">Add</span></button>

I use the following code to click on the button:

xpath = "//button[@data-automation-id='wd-ActiveList-addButton']"
add = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, xpath)))
add.click()

It always results in the following error:

selenium.common.exceptions.TimeoutException: Message:

I have tried using different ways to find the element and click, but always get the same error. The button is not inside an iframe. Moreover, I'm able to access/click on all elements around the button. As the error message is empty, I'm clueless as to why this happens.

EDIT

Here's some surrounding code from the inspector:

<div class="WF-M WFN WOYM WEYM" id="wd-SectionView-NO_METADATA_ID">
    <div class="WH-M">
        <div class="WOO WFN" data-automation-id="activeList" id="wd-ActiveList-  6$87772">
            <div class="WHP">
            </div>
            <button class="WAXG WEXG WKKH WOWG WPO" tabindex="0" data-automation-activebutton="true" aria-hidden="false" aria-disabled="false" data-automation-id="wd-ActiveList-addButton" role="button" data-automation-button-type="AUXILIARY" title="Add" type="button">
                <span class="WFXG WBXG"></span>
                <span class="WCXG" title="Add">Add</span>
            </button>
        </div>
    </div>
</div>
12
  • 1
    what if you try clicking the span instead of the button? xpath = "//span[@title='Add']"? There is a chance the button isn't actually visible or has a size of 0. Not very likely given the html here, but possible. You could also try using devtools or firepath to see what element is highlighted when you put your mouse over the button, as it could actually be an element that contains the button. Commented Mar 17, 2017 at 15:55
  • 2
    Check if this is the only element with specified selector print(len(driver.find_elements_by_xpath("//button[@data-automation-id='wd-ActiveList-addButton']"))). There might be same hidden button Commented Mar 17, 2017 at 16:07
  • @mrfreester I still get the same error using xpath = "//span[@title='Add']". Firepath generated the following xpath for the button when I clicked on it: .//*[@id='wd-ActiveList-6$87772']/button. Commented Mar 17, 2017 at 16:20
  • @Andersson I tried that and it prints 0. I tried different identifiers, still 0. Commented Mar 17, 2017 at 16:21
  • Can you share page URL? Commented Mar 17, 2017 at 16:24

1 Answer 1

1

As I've already assumed in comments there are two buttons on page that can be found by attribute data-auto‌​mation-id='wd-Active‌​List-addButton': the first is hidden. That's why your expectation to wait until it become visible always returns False

You might need to use below code:

xpath = "(//button[@data-automation-id='wd-ActiveList-addButton'])[2]"
add = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, xpath)))
add.click()

It should allow you to click visible "Add" button

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.