- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对自动化测试完全陌生。在引用了一些教程后,我创建了一个自动化测试用例。我尝试自动化的测试用例是检查单击表格标题之一后排序是否正确。
我的自动化测试用例因以下异常而失败:
org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM
Command duration or timeout: 12 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.35-30-generic', java.version: '1.6.0_20'
Driver info: driver.version: RemoteWebDriver
Session ID: 95b80ea0-26ac-45e0-a407-79f5b687504a
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:244)
at org.openqa.selenium.remote.RemoteWebElement.findElements(RemoteWebElement.java:169)
at org.openqa.selenium.remote.RemoteWebElement.findElementsByTagName(RemoteWebElement.java:240)
at org.openqa.selenium.By$ByTagName.findElements(By.java:312)
at org.openqa.selenium.remote.RemoteWebElement.findElements(RemoteWebElement.java:151)
at Sorting.sorting_column(Sorting.java:68)
代码如下:
//Fetching values from the column of a table
WebElement table = driver.findElement(By.id("dnn_ctr381_View_DealerList_ctl00"));
List<WebElement> rows = table.findElements(By.tagName("tr"));
for (WebElement row : rows) {
List<WebElement> cells = row.findElements(By.tagName("td"));
if (!cells.isEmpty() && cells.get(0).isDisplayed()) {
a = cells.get(0).getText();
}
b[i] = a;
i++;
}
//Click on column header to sort
driver.findElement(By.cssSelector("html body#Body form#Form div#container.container div#Wrapper div#Main div#Panes div#ContentsContainer.box-shadow div#Contents div#Content div#dnn_ContentPane.MainContent div.DnnModule div.dnnPEMContNotitle div#dnn_ctr381_ContentPane.dnnPEMContNotitleBody div#dnn_ctr381_ModuleContent.DNNModuleContent div#dnn_ctr381_View_dnn_ctr381_View_DealerListPanel div#dnn_ctr381_View_DealerList.RadGrid table#dnn_ctr381_View_DealerList_ctl00.rgMasterTable thead tr th.rgHeader a")).click();
WebElement table1 = driver.findElement(By.id("dnn_ctr381_View_DealerList_ctl00"));
List<WebElement> rows1 = table1.findElements(By.tagName("tr"));
for (WebElement row1 : rows1) {
List<WebElement> cells1 = row1.findElements(By.tagName("td"));// Exception here
if (!cells1.isEmpty() && cells1.get(0).isDisplayed())
{
c = cells1.get(0).getText();
}
异常来自这一行:
List<WebElement> cells = row1.findElements(By.tagName("td"));
有人可以告诉我这个问题的原因以及如何解决吗?
感谢任何帮助
最佳答案
StaleElementException
是为了告诉您在客户端代码中(通过 findElement
)引用的 DOM 元素不再存在。在您的情况下,row1
元素不再存在。这当然是一个时间问题,因为您点击排序就在上面,并且没有注意确保排序已完成。如果没有更多地了解排序是如何实现的,或者需要多长时间,这将是我最好的猜测。如果在迭代 DOM 对象时排序结束,这些对象将在 DOM 中重新排列并在客户端代码中丢失
关于selenium - StaleElementReferenceException : Element is no longer attached to the DOM: Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14136122/
我正在尝试发送一封带有附件和 html 内容的邮件。我知道如何分别发送 html 内容和附件,但是是否可以同时发送 html 和附件? 这是我尝试过的: public static void send
所以我真的很难弄清楚什么时候应该附加到一个对象,什么时候不应该附加到一个对象。首先,这是我的(非常简化的)对象模型的小图。 在我的 DAL 中,我每次执行与数据相关的操作时都会创建一个新的 DataC
更新:Docker 0.9.0 现在使用 libcontainer,从 LXC 转移参见:Attaching process to Docker libcontainer container 我正在运
我按照此页面上的说明进行操作: https://developers.facebook.com/docs/plugins/share-button/#settings 我得到一个工作共享对话框,但是当
我有一个现有代码可以正确下载和处理一些电子邮件。 要处理的电子邮件必须有一个或多个 xml 作为附件,现在我正在迁移这个过程从当前的标准邮件帐户到一个认证系统,该系统将邮件包装到一个新的电子邮件。 因
我不太明白通过 attach api 连接到另一个虚拟机是什么意思.我读到每个 Java 程序都在其自己的虚拟机中运行(参见 here )。那么对于一个程序“附加”到另一个 jvm 进程以便它可以访问
无论如何我可以强制使用这种方法,ActiveStorage::Attached#attach不排队后台工作?换句话说,我想禁用似乎包含在 ActiveStorage::Attached#attach
在 Eclipse 插件开发中,我通过 MANIFEST.MF 文件导入包。所以我没有 lib 文件夹,也没有引用的库部分。 即使对于像 String.format() 这样最基本的方法,我也看不到
我不知道执行此操作的确切方法。我想要一种方法,而不是针对 Eclipse 中所有项目的单个项目。请告诉我如何解决这个问题。 最佳答案 这是在 Eclipse 中的类路径中的一个 jar,你有 附加了一
我有一个多个文件要附加到选择器 View 中。当用户选择该选择器 View 项目时,他们可以单击电子邮件按钮来附加所选文件。我该如何在选择器 View 中执行此操作? 这是我的示例代码。 M 文件:
经过this之后通过讨论,我相信附加到同一虚拟机的选项默认情况下已在 OpenJDK11 中禁用。 我正在尝试将 java 代理升级到 OpenJDK11,在测试用例中,当调用 VirtualMach
首先 - 我知道 UWSGI 建议使用 smart-attach-daemon 来自:http://uwsgi-docs.readthedocs.io/en/latest/AttachingDaemo
我使用axios从Reaction网站调用我的API(Django服务器),我希望在授权头的每个请求中都出现一个带有持有者令牌的授权头。。这就是我如何设置授权头apiClient.defaults.h
我在 heroku 上有一个 rails 应用程序,我无法运行我最新的数据库更改。运行 heroku run rake db:migrate给我 Running `rake db:migrate` a
我使用 strope.js 构建一个简单的 IM(web)。 我有 2 个页面:index.html(用于登录)和 myChat.html(主聊天 View )。 当我通过index.html中的ji
我尝试过“heroku run python manage.py migrate”并收到“超时等待dyno,请参阅https://devcenter.heroku.com/articles/one-o
我正在使用 OpenGL 帧缓冲区对象 (FBO) 在 iOS 上实现模板阴影。代码有效——也就是说,从视觉上看,模板缓冲区正在完成这项工作,而且性能似乎还不错。 但是,当我通过 OpenGL ES
我正在尝试使用 slack 附件来记录应用程序错误,但是像堆栈跟踪这样的大字段表现得很奇怪。 首先,当使用附件时,表格似乎固定为任意宽度,是否有任何更改,以便可以允许更宽的值?否则 50+% 的松弛窗
我花了好几天时间寻找一种解决方案,将带有附件的属性字符串放到 NSPasteboard 上。 我可以读取带有附件的 RTFD 文件,修改其文本和属性,然后将其粘贴到 NSPasteboard 上以供其
我想对数据框的列进行许多修改。但是,由于需要大量的列和转换,我想避免一遍又一遍地使用数据框名称。 在 SAS 数据步中,在一个数据步中,您可以创建一个变量并在定义后立即引用它: data A; s
我是一名优秀的程序员,十分优秀!