- #xpath:attributor (attribute)
- driver.find_element_by_xpath("//input[@id='kw']").send_keys("selenium")
- Element with id = kw under the #input tag
- #xpath:idRelative (id correlation)
- driver.find_element_by_xpath("//div[@id='fm']/form/span/input").send_keys("selenium")
- #There is an element with id=fm of the div tag under the /form/span/input level tag
- driver.find_element_by_xpath("//tr[@id='check']/td[2]").click()
- # The tr with id of 'check' will flash the second one in it
- #xpath:position (position)
- driver.find_element_by_xpath("//input").send_keys("selenium")
- driver.find_element_by_xpath("//tr[7]/td[2]").click()
- #The second td in the seventh tr
- #xpath: href (horizontal reference)
- driver.find_element_by_xpath("//a[contains(text(),'网页')]").click()
- #Under the a tag there is an element with text (text) that contains (contains) 'web page'
- #xpath:link
- driver.find_element_by_xpath("//a[@href='http://www.baidu.com/']").click()
- #There is a tag called a, he has a link href='http://www.baidu.com/ element
Several uses of xpath
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326849931&siteId=291194637
Recommended
Ranking