使用xpath调试不通过
目前使用python2.7版本,是什么原因,感觉自己写的脚本没问题,但总是报错,脚本改了各种方式,其他正常find_element_by_id啊等都能用。就path用不了。请大家帮忙看下。脚本:
dingdan = driver.find_element_by_xpath("//div[@id='erpHeaderMenus']/div")
ActionChains(driver).move_to_element(dingdan).perform()
报错如下:
Traceback (most recent call last):
File "C:\Python27\test1.py", line 22, in <module>
dingdan = driver.find_element_by_xpath("//*[@id='erpHeaderMenus']/div")
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
NoSuchElementException: Message: Unable to locate element: //*[@id='erpHeaderMenus']/div python版本已经升级到3.3,依然不行,在线等大神 dingdan = driver.find_element_by_xpath("//div[@id='erpHeaderMenus']")就不报错,很奇怪 自己研究出来了,谢谢大家 是不是定位出现了问题 恭喜 :lol :)
页:
[1]