问题描述
- 用 driver.find_element_by_link_text('退出').click()异常
-
问题:
python+seleniu做自动化用 driver.find_element_by_link_text('退出').click()做qq邮箱退出操作程序异常,求大神解答一下哪里有问题!异常情况如下:
File "D:/PycharmProjects/untitled/mainTest.py", line 13, in
login().user_logout(driver)
File "D:PycharmProjectsuntitledLoginPublic.py", line 24, in user_logout
driver.find_element_by_link_text('退出').click()
File "C:Python27libsite-packagesseleniumwebdriver
emotewebdriver.py", line 282, in find_element_by_link_text
return self.find_element(by=By.LINK_TEXT, value=link_text)
File "C:Python27libsite-packagesseleniumwebdriver
emotewebdriver.py", line 712, in find_element
{'using': by, 'value': value})['value']
File "C:Python27libsite-packagesseleniumwebdriver
emotewebdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "C:Python27libsite-packagesseleniumwebdriver
emoteerrorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementExceptionProcess finished with exit code 1
解决方案
这个是因为浏览器没有找到element的原因。
没有找到element的话,大概有几个原因:
1.确认是否存在这个元素。它的link_text是不是“退出”两个字。
2.观察一下浏览器,看看是不是这个元素没有加载出来。
解决方案二:
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'xml-bod
[Repost]Selenium ElementNotVisibleException: Cannot click on element
media in the link element -CSS and select by #id
解决方案三:
http://blog.csdn.net/intel80586/article/details/8783279