sturnjunjun
sturnjunjun
2017-05-10 09:47

selenium操作元素时候报 Element is no longer valid

50
  • exception
  • selenium
  • browser

selenium能够定位到元素,但是操作元素时候报 Element is no longer valid

from selenium import webdriver
import time
browser = webdriver.Ie()
browser.maximize_window()
browser.get('URL')

elem = browser.find_element_by_css_selector("#username")

elem.click()___
网上给的方法已经都试过了,什么等待,refresh页面等等,都不可以,有没有大神帮忙解决一下呢,错误信息如下
elem.click()
File "C:\Python27\lib\site-packages\selenium-2.52.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 75, in click
self._execute(Command.CLICK_ELEMENT)
File "C:\Python27\lib\site-packages\selenium-2.52.0-py2.7.egg\selenium\webdriver\remote\webelement.py", line 469, in _execute
return self._parent.execute(command, params)
File "C:\Python27\lib\site-packages\selenium-2.52.0-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium-2.52.0-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: Element is no longer valid

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答

为你推荐