我尝试使用python selenium定位元素,并有以下代码:
zframe = driver.find_element_by_xpath("/html/frameset/frameset/frame[5]")
driver.switch_to.frame(zframe)
findByXpath("/html/body/form/table/tbody/tr/td[2]/label[3]").click()
element = driver.find_element_by_xpath("//*[@id='awdType']")
我得到的错误是:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='awdType']"} (Session info: chrome=59.0.3071.115)
你知道为什么它找不到这个元素吗?我通过复制和交换帧来使用精确的xpath。谢谢!在
问题的发生是因为
awdType
是通过ajax或jquery加载的。 您应该使用selenium Waits.有两种类型的等待显式和隐式。避免使用隐式等待。或者
^{pr2}$相关问题 更多 >
编程相关推荐