0

In a page there are a list of buttons. Source code of each button is the same except for the link text.

I need to confirm the all the buttons in one page are clickable using WebDriverWait.until. I can the following WebDriverWait(driver,10).until(ec.element_to_be_clickable(By.XPATH,'//a[@class="ng-scope"]')) to confirm the first button to be clickable, but how can I confirm the second one without using the text feature(abc|efg)?

Any suggestion to extract the index within xpath? Thank you.

<li class="ng-scope" ng-report="one in typelist">
    <a class = "btn ng-binding" ng-class="{aabbcc}"> abc</a>
</li>
<li class="ng-scope" ng-report="one in typelist">
    <a class = "btn ng-binding" ng-class="{aabbcc}"> efg</a>
</li>
user3182473
  • 63
  • 1
  • 9

2 Answers2

0

You can search with xpath by index

WebDriverWait(driver, 10).until(ec.element_to_be_clickable(By.XPATH, "//a[@class='ng-scope'][2]"))

This will give you the second button.

Guy
  • 46,488
  • 10
  • 44
  • 88
  • For the second ng-scope, It should be [2] not [1]. check this : [http://selenium-python.readthedocs.org/locating-elements.html](http://selenium-python.readthedocs.org/locating-elements.html) – dvenkatsagar Jan 25 '16 at 09:28
  • @dvenkatsagar I found why (although your example was some what vague, look [here](http://stackoverflow.com/questions/3319341/why-do-indexes-in-xpath-start-with-1-and-not-0)). Thanks. – Guy Jan 25 '16 at 09:33
0

Try Capturing all the element to a list and iterate through each for checking if they are clickable

Siva
  • 1,129
  • 1
  • 8
  • 13