How to locate a span with a specific text in Selenium? (Using Java)

后端 未结 2 1289
你的背包
你的背包 2021-02-04 15:04

I\'m having trouble locating a span element in Selenium using java.

the HTML looks like:

2条回答
  •  忘掉有多难
    2021-02-04 15:43

    For the element below

    
        Test Text
    
    

    The following solution works for me

    driver.find_element_by_xpath("//span[contains(@class, 'test-button__text') and text()='Test Text']")
    

提交回复
热议问题