Selenium how to select an object by class Selenium how to select an object by class selenium selenium

Selenium how to select an object by class


Use XPath selector in Selenium:

xpath=//li[contains(@class, 'ui-autocomplete')]/li[1]/a

not checked, might require some corrections.


in response to "Can I do a jQuery type of selector," jQuery uses CSS selectors. Selenium can also use CSS selectors; just prefix the selector with "css=". so:

css=.ul.ui-autocomplete li:first a


Next way to use xpath like this

xpath=/html/body/ul[2]/li[1]/a