python+selenium,html嵌套,xpath是对的,怎么都定位不到

python+selenium,html嵌套,xpath是对的,怎么都定位不到

刚学习python,用Xpath怎么都定位不到,但是路径是对的,这时候可能是html嵌套,就是html里边还有一个html

解决方法如下:

python+selenium,html嵌套,xpath是对的,怎么都定位不到_第1张图片

driver.switch_to.frame('ifsidebar')
driver.find_element_by_xpath('/html/body/form/div[3]')
driver.find_element_by_xpath('/html/body/form/div[3]/div[2]/ul/li[19]/a/label').click()
driver.switch_to.default_content()

记得跳出去啊:driver.switch_to.default_content()

你可能感兴趣的:(python+selenium)