Selenium Webdriver finding an element in a sub-element

前端 未结 4 1200
臣服心动
臣服心动 2021-01-30 01:38

I am trying to search for an element in a sub-element with Selenium (Version 2.28.0), but selenium des not seem to limit its search to the sub-element. Am I doing this wrong or

4条回答
  •  有刺的猬
    2021-01-30 01:51

    Use the following:

    element2 = driver.find_element_by_cssselector("css=div[title='div2']")
    element2.find_element_by_cssselector("p[@class='test']").text 
    

    Please let me know if you have any problems.

提交回复
热议问题