我有一个类型为boolean“worklogMatch”的标志。我需要为'true'声明这个标志。如果不是这样,我需要打印ERROR值。这是我的代码,
List<WebElement> worklogObj = driver().findElements(By.xpath("//div[@class='ng-scope']");
boolean worklogMatch = false;
ArrayList<String> worklogDescriptions = new ArrayList<String>();
for(int i=0; i<worklogObj.size(); i++) {
worklogDescriptions.add(worklogObj.get(i).getText());
log.info("Text of the worklogs: "+worklogObj.get(i).getText());
if (worklogObj.get(i).getText().equals(worklogDescription)){
worklogMatch = true;
break;
}
}
assertTrue(worklogMatch == true, "worklog Description "+worklogDescription + " is not saved. List of "+ "worklog description found for the incident " +incidentNumber +" is" + worklogDescriptions);
当我断言这一点时,布尔变量worklogMatch被设置为false,因为我正在寻找的String不存在于ArrayList中。测试用例按预期失败。但是,该控制台中没有显示该消息。我的问题,
答案 0 :(得分:0)
现在断言看起来像:
assertTrue("worklog Description "+worklogDescription + " is not saved. List of "+ "worklog description found for the incident " +incidentNumber +" is" + worklogDescriptions, worklogMatch);