I have a web page with a form and has a field that uses the jquery autocomplete function.
This is how the HTML renders after a user name returns 1 or more results.
However I cannot figure out how to make Selenium "click" a result.
Can I do a jQuery type of selector. e.g.
$(".ul.ui-autocomplete li:first a")
The select class allows us to select an element from the drop-down and lists that are created with the HTML <select> element. The select class is present in org. openqa. selenium.
Initializes a new instance of the By class using the given functions to find elements. Gets or sets the value of the description for this By class instance. Gets or sets the method used to find a single element matching specified criteria. Gets or sets the method used to find all elements matching specified criteria.
We can find an element using the attribute class name with Selenium webdriver using the locators - class name, css, or xpath.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With