标题: selenium显示Message: no such element [打印本页] 作者: lovelorn0327 时间: 2015-2-3 22:38 标题: selenium显示Message: no such element 进入新浪首页,想点击【NBA】这个Link
<a href="http://sports.sina.com.cn/nba/">NBA</a>
然后使用Xpath
driver.find_element_by_xpath('//a[href="http://sports.sina.com.cn/nba/"]').click()_ 然后运行到这一步就报错了
Traceback (most recent call last):
File "D:/testspace/webTest.py", line 19, in <module>
driver.find_element_by_xpath('//a[href="]http://sports.sina.com.cn/nba/"]').click()
File "D:\tools\python2.7.9\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 230, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "D:\tools\python2.7.9\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 662, in find_element
{'using': by, 'value': value})['value']
File "D:\tools\python2.7.9\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute
self.error_handler.check_response(response)
File "D:\tools\python2.7.9\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element
(Session info: chrome=40.0.2214.93)
(Driver info: chromedriver=2.13.307647 (5a7d0541ebc58e69994a6fb2ed930f45261f3c29),platform=Windows NT 6.1 SP1 x86)