PageFactory 中的 StaleElementReference 异常 [英] StaleElementReference Exception in PageFactory

本文介绍了PageFactory 中的 StaleElementReference 异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习 PageFactory 模型.我理解当我们执行 initElements 时,WebElements 被定位的事实.例如,我点击了一个 webelement,因此 DOM 中的其他 webelement 之一发生了变化.现在,显然我会在这里得到一个 StaleElementReferenceException.我将如何解决这个问题?

I am trying to learn the PageFactory model. I understood the fact that when we do a initElements, the WebElements are located. Say for example, I click on a webelement and because of which there is a change in one of the other webelements in DOM. Now, obviously I would get a StaleElementReferenceException here. How would I resolve this issue?

如果知道 DOM 中 WebElement 的属性可能会发生变化这一事实,我是否应该再次找到该特定 WebElement?或者有其他方法可以解决这个问题吗?

Should I find that specific WebElement again knowing the fact that there can be a change in the WebElement's properties in the DOM? or is there an another way to handle this?

推荐答案

StaleElementReferenceException

StaleElementReferenceException 扩展 WebDriverException 并表示之前引用的元素现在陈旧,元素引用不再出现在页面的 DOM 上.

StaleElementReferenceException

StaleElementReferenceException extends WebDriverException and indicates that the previous reference of the element is now stale and the element reference is no longer present on the DOM of the page.

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆