首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >有没有办法对变量进行硒chromedriver调试

有没有办法对变量进行硒chromedriver调试
EN

Stack Overflow用户
提问于 2019-04-01 23:32:55
回答 1查看 0关注 0票数 0

这个问题在这里已有答案:

  • StofElementReference PageFactory 3答案中的 异常
  • 使用Python 2答案 迭代时的StaleElementException

在selenium with python,我使用循环find_elements_by_css_selector并找到attribute

并测试是否有错误

代码语言:javascript
复制
   while(1):
            try:
                temp = screen_list.get_attribute('screen_cd')
                break
            except :
                print(screen_list)
                continue

前1分钟正常运行,但出现错误。并在下面重复代码

代码语言:javascript
复制
<selenium.webdriver.remote.webelement.WebElement (session="eeb3954f16d94e9f3988cd0aa0d2f2b7", element="0.9896629491981219-171")>

我想看看screen_list,所以我使用print(screen_list.text)和以下错误发生,不重复只是停止

代码语言:javascript
复制
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

我可以跳过这个错误,但我想调试像C ++(参见值和状态)

有没有办法对变量进行硒chromedriver调试?

EN

回答 1

Stack Overflow用户

发布于 2019-04-02 09:10:35

我相信您引用的元素已无法供您使用。经过这样的持续时间和多个get_attribute()可以解释这种情况。我建议在你的循环中使用get_attribute()之前使用find_elements_by_css_selector,以确保你的元素引用不会过时:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100006538

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档