【发布时间】:2015-03-28 04:23:23
【问题描述】:
我有这个下一个按钮,脚本一直单击该按钮,直到它到达最后一页。它应该读取并比较每个页面中的数据,然后在禁用按钮后退出循环。当下一个按钮处于启用状态时,它读取数据并进行比较没有问题,但是当下一个按钮被禁用时,脚本不会读取该页面
这是元素
这是我的代码
do {
....
....
if(driver.findElement(By.id("ReportViewer1_ctl06_ctl00_Next_ctl00_ctl00")).isDisplayed()) {
driver.findElement(By.id("ReportViewer1_ctl06_ctl00_Next_ctl00_ctl00")).click();
} else {
}
} while(driver.findElement(By.id("ReportViewer1_ctl06_ctl00_Next_ctl00_ctl00")).isDisplayed());
问题是当到达第二页时,next 按钮被禁用并且 While 退出而不读取第 2 页中的数据。
如何确保页面被阅读
当只有一页数据时(所以下一个按钮将在开始时被禁用)
到达最后一页时,(下一个按钮变为禁用状态)
我曾尝试过 FluentWait,但失败了,如此处所述https://stackoverflow.com/questions/29282178/selenium-fluentwait-method-failing-to-ignore-nosuchelement
EDIT..为按钮的禁用状态添加了 HTML
<td>
<input id="ReportViewer1_ctl06_ctl00_Next_ctl01_ctl00" type="image"
style="border-style: none; height: 16px; width: 16px; border-width: 0px; cursor: default;"
alt="Next Page" src="/xxxx Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=
0.0.30319.1&Name=Microsoft.Reporting.WebForms.Icons.NextPageDisabled.gif"
title="Next Page" disabled="disabled" name="ReportViewer1$ctl06$ctl00$Next$ctl01$ctl00">
再次编辑 --- 启用按钮时的 HTML(没有禁用属性)
<input id="ReportViewer1_ctl06_ctl00_Next_ctl00_ctl00" type="image" style="border-style:
none; height: 16px; width: 16px; border-width: 0px;" alt="Next Page"
src="/xxxxx/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=10.0.30319.
1&Name=Microsoft.Reporting.WebForms.Icons.NextPage.gif"
title="Next Page" name="ReportViewer1$ctl06$ctl00$Next$ctl00$ctl00">
【问题讨论】: