这个问题在这里已有答案:
在selenium with python,我使用循环find_elements_by_css_selector
并找到attribute
并测试是否有错误
while(1):
try:
temp = screen_list.get_attribute('screen_cd')
break
except :
print(screen_list)
continue
前1分钟正常运行,但出现错误。并在下面重复代码
<selenium.webdriver.remote.webelement.WebElement (session="eeb3954f16d94e9f3988cd0aa0d2f2b7", element="0.9896629491981219-171")>
我想看看screen_list,所以我使用print(screen_list.text)
和以下错误发生,不重复只是停止
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
我可以跳过这个错误,但我想调试像C ++(参见值和状态)
有没有办法对变量进行硒chromedriver调试?
发布于 2019-04-02 09:10:35
我相信您引用的元素已无法供您使用。经过这样的持续时间和多个get_attribute()可以解释这种情况。我建议在你的循环中使用get_attribute()之前使用find_elements_by_css_selector,以确保你的元素引用不会过时:)
https://stackoverflow.com/questions/-100006538
复制相似问题