Selenium Webdriver finding an element in a sub-element

前端 未结 4 1212
臣服心动
臣服心动 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 02:12

    This is how you search for element or tag in CSS subclass and I believe that it works for multilevel situation as well:

    Sample HTML:

  • Posted:
  • This is how you would get pubdate tag value for example.

    published = driver.find_element_by_css_selector('li>time').get_attribute('datetime')
    

提交回复
热议问题