每次我运行我的测试用例时,其中一些放置是间隔开的,而其他放置是连接的,为什么这样和修复是什么?这是一个示例代码和控制台输出Console output results`
的图片 if(driver.getPageSource().contains("Create Report"))
{
System.out.println(" Test Case 2a Report Page Create Report Field Passed");
}
else{
System.out.println(" Test Case 2a Report Page Create Report Field Failed");
}
Thread.sleep(3000);
// Quick Reports
// Ensure the dates are visible
if(driver.getPageSource().contains("Quick Reports"))
{
System.out.println(" Test Case 2b Report Page Quick Reports Field Passed");
}
else{
System.out.println(" Test Case 2b Report Page Quick Reports Field Failed");
}
Thread.sleep(3000);
// Last Week
// Ensure Last Week Link Text is present
boolean isDisplayed1 = driver.findElement(By.xpath(".//*[@id='block-2']/div/table/tbody/tr/td[2]/div[1]/div/div[2]/div[1]/a")).isDisplayed();
if (isDisplayed1) {
System.out.print(" Test Case 2c Last Week Link Text Present");
}else{
System.out.print(" Test Case 2c Last Week Link Text not Present");
}
Thread.sleep(2000);
// Last Month
// Ensure Last month link text present
boolean isDisplayed2 = driver.findElement(By.xpath(".//*[@id='block-2']/div/table/tbody/tr/td[2]/div[1]/div/div[2]/div[3]/a")).isDisplayed();
if (isDisplayed2) {
System.out.print(" Test Case 2d Last Month Link Text Present");
}else{
System.out.print(" Test Case 2d Last Month Link Text not Present");
}
Thread.sleep(3000);
// Year to Date
// Ensure Year to Date Link Text is present
boolean isDisplayed3 = driver.findElement(By.xpath(".//*[@id='block-2']/div/table/tbody/tr/td[2]/div[1]/div/div[2]/div[5]/a")).isDisplayed();
if (isDisplayed3) {
System.out.print(" Test Case 2e Year to Date Link Text Present");
}else{
System.out.print(" Test Case 2e Last Year tp Date Link Text not Present");
}
Thread.sleep(3000);`
答案 0 :(得分:1)
如果我理解正确,你会问为什么有些输出会在新行上打印,而其他输出则没有。
那是因为在某些地方你使用
System.out.println
打印字符串并将光标移动到新行。有时候你会用
System.out.print
打印字符串,不将光标移动到新行。