1.定位元素的父元素
driver.find_element_by_xpath(“//p[@id=‘one’]/parent::p”)
#定位id为one 的p标签元素。
2.定位包含文本“采购人信息”的span元素的父元素p的同级下一个元素
driver.find_element_by_xpath(‘//span[contains(text(),“采购人信息”)]/parent::p/following-sibling::p’)
3.定位包含文本“采购人信息”的span元素的父元素p的同级上一个元素
driver.find_element_by_xpath(‘//span[contains(text(),“采购人信息”)]/parent::p/preceding-sibling::p’)
4.定位元素的标签以某内容开始或结束
driver.find_element_by_xpath(“//span[starts-with(@name,‘内容’)]”)
driver.find_element_by_xpath(“//span[end-with(@name,‘内容’)]”)
定位span元素,name属性以某“内容”开始或结束。