Python Selenium Webdriver Help
I have a website that has the same titled button several times on the page. I want to be able to click a certain one of these buttons. The only thing I can see that is different is the second number set in the ( ). In this example it is 123883445. Below is the results of the "inspect element"
<a style="position: relative;" class="vote_link vote" href="#" onclick="SST.vote_for(widget_47929421, 123883455, this); return false;" title="Vote">Vote</a>
How can I find then select this element by using the number 123883455?
There's a couple ways to go about this, depending on the behavior of the application.
Probably the most straightforward - assuming that the number 123883455 is always the same (not dynamically generated on page load) for the button you want - is to use a css attribute locator:
element = driver.find_element_by_css_locator("a[onclick*='123883455']")
That should return the single button you want to click. You could do a similar thing using xpath as well.
Or, if the button is always in the same position on the page (for example, it is always the 3rd "vote" button, you could do something like this...
element = driver.find_elements_by_css_locator("a.vote_link")
That would get a collection of all the matching elements and return the third one.