Several uses of xpath

  1. #xpath:attributor (attribute)  
  2. driver.find_element_by_xpath("//input[@id='kw']").send_keys("selenium")  
  3. Element with id = kw under the #input tag  
  4. #xpath:idRelative (id correlation)  
  5. driver.find_element_by_xpath("//div[@id='fm']/form/span/input").send_keys("selenium")  
  6. #There is an element with id=fm of the div tag under the /form/span/input level tag  
  7. driver.find_element_by_xpath("//tr[@id='check']/td[2]").click()  
  8. # The tr with id of 'check' will flash the second one in it  
  9. #xpath:position (position)  
  10. driver.find_element_by_xpath("//input").send_keys("selenium")  
  11. driver.find_element_by_xpath("//tr[7]/td[2]").click()  
  12. #The second td in the seventh tr  
  13. #xpath: href (horizontal reference)  
  14. driver.find_element_by_xpath("//a[contains(text(),'网页')]").click()  
  15. #Under the a tag there is an element with text (text) that contains (contains) 'web page'  
  16. #xpath:link  
  17. driver.find_element_by_xpath("//a[@href='http://www.baidu.com/']").click()  
  18. #There is a tag called a, he has a link href='http://www.baidu.com/ element  

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326849931&siteId=291194637