selenium操作元素时候报 Element is no longer valid
selenium能够定位到元素,但是操作元素时候报 Element is no longer validfrom selenium import webdriverimport 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
加点等待时间 在两次点击中间加一定的等待时间 是不是还没出现元素 多加一些思考时间 css_selector("#username") 这个方法正确吗换其他试试
页:
[1]