Selenium how to select an object by class

后端 未结 4 1861
夕颜
夕颜 2021-02-07 04:28

I have a web page with a form and has a field that uses the jquery autocomplete function.

\"enter

相关标签:
4条回答
  • 2021-02-07 05:01

    Use XPath selector in Selenium:

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

    not checked, might require some corrections.

    0 讨论(0)
  • 2021-02-07 05:14

    Next way to use xpath like this

    xpath=/html/body/ul[2]/li[1]/a
    
    0 讨论(0)
  • 2021-02-07 05:17

    Suppose you have a dynamic XPATH then you can point to an element like this

    driver.findElement(By.className(""));

    0 讨论(0)
  • 2021-02-07 05:22

    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
    
    0 讨论(0)
提交回复
热议问题