我有这个动态页面,它根据数据统计变化。 每当一页测试完成时,我都必须单击下一页。 为此,我具有测试脚本,该脚本将从应用程序捕获页面计数。 我在下面使用的JAVA代码不知道哪里出错了,因为我没有收到任何错误消息
// Page 1 is always present
Reporter.log("Successfully rendered View Portfolios Page 1");
Add_Log.info("Successfully rendered View Portfolios Page 1");
//This is fetching page count from the application which I convert to Int
String entriesTxt = driver.findElement(By.xpath("(//label[contains(@class,'pf-pageNo-label')])[2]")).getText().trim();
String[] aEntriesText = entriesTxt.split(" ");
String totalEntriesText = aEntriesText[aEntriesText.length - 1];
int result = Integer.parseInt(totalEntriesText);
System.out.println(result);
// Page 2
// This if Page count is great than 1 then perform below action
if (result > 1) {
pagenew(driver, Filters[1]);
Reporter.log("Successfully rendered View Portfolios Page 2");
Add_Log.info("Successfully rendered View Portfolios Page 2");
Thread.sleep(3000);
}
// Page 3
// This if Page count is great than 2 then perform below action
if (result < 2) {
pagenew(driver, Filters[2]);
Reporter.log("Successfully rendered View Portfolios Page 3");
Add_Log.info("Successfully rendered View Portfolios Page 3");
Thread.sleep(3000);
}
使用上面的代码,它正在渲染此语句不起作用的所有页面 如果(结果> 1) 我希望如果result = 1
,则第2页不应该呈现答案 0 :(得分:0)
我最好的猜测是,而不是
...
if (result < 2) {
...
你想写
...
if (result > 2) {
...
因此,即使结果为1,也会呈现第3页。