获取元素文本与属性

For instance, consider this page source:

  1. <html>
  2. <body>
  3. <p id="content">Site content goes here.</p>
  4. </body>
  5. <html>
  • 元素p 文本内容

element = driver.find_element_by_id("element")element.text

  • 元素p 属性

element.get_attribute('id')