[英]Java If value is greater than perform
我有这个动态页面,它根据数据计算变化。 每次完成一页测试时,我都必须单击下一页转到下一页。 为此,我有测试脚本,它将从应用程序中捕获页数。 我使用的 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);
}
使用上面的代码,它正在呈现所有页面,如果 (result > 1) 我希望页面 2 不应该呈现如果结果 = 1,则此语句不起作用
我最好的猜测是,而不是
...
if (result < 2) {
...
你想写
...
if (result > 2) {
...
因此,即使结果为 1,您的第 3 页也会呈现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.