What are some good ways to get a specific element in WebDriver / Selenium2, based only on the text inside the element?
<div class="page"> <ul id="list"> <li>Apple</li> <li>Orange</li> <li>Banana</li> <li>Grape</li> </ul> </div>
Essentially, I would like to write something like this to get a specific element:
@driver.find_element(:id, "list").find_element(:text, "Orange")
This is very similar to the way I will use the selector when searching for text inside a link (i.e :link_text or :partial_link_text ), but I would like to find elements by text inside regular, unrelated links.
Any suggestions? How do you deal with this problem? (If you're interested, I use Ruby.)
bbbco source share