如何解决Jenkins中的“范围报告”正在显示空白的屏幕截图图标
我已经生成了我的项目的可运行jar,并通过jenkins在其他计算机上运行了它。 Jar文件成功执行并生成范围报告, 但屏幕截图的位置上有一个空白图标。
我已经在Google上进行了搜索,但是没有找到任何相关的解决方案来解决我的问题。
- 我正在使用Intellij IDE,并使用“在浏览器中打开”选项打开范围报告。 当范围报告附加了两个以上的屏幕截图时(如上例),在新选项卡中打开图像时,该屏幕显示空白图标并显示错误。 (当进入范围报告时,进入实际保存在系统中的文件夹中,它将按预期方式工作。)
我的代码:
@BeforeTest
public void setExtent() {
extent = new ExtentReports(System.getProperty("user.dir")+ "/test-output/Login.html",true);
System.out.println("KKKKKKK");
extentTest = extent.startTest("Start the Execution");
extent.addSystemInfo("Host Name","Live Contract");
extent.addSystemInfo("User Name","Shivam Goyal");
extent.addSystemInfo("Environment","Develop");
extentTest.log(LogStatus.INFO,"Test Execution started");
}
public static String getScreenshot(WebDriver driver,String screenshotName) {
String dateName = new SimpleDateFormat("ddMMyyyyhhmmss").format(new Date());
TakesScreenshot ts = (TakesScreenshot) driver;
File src = ts.getScreenshotAs(OutputType.FILE);
String path = System.getProperty("user.dir")+ "/test-output/"+ screenshotName + dateName + ".png";
File destination = new File(path);
try {
FileUtils.copyFile(src,destination);
}
catch(IOException e){
System.out.println("Capture Failed" +e.getMessage());
}
return path;
}
@Test
public void openURL() throws IOException,InterruptedException,HeadlessException,UnsupportedFlavorException {
System.out.println("test openWeb");
extentTest = extent.startTest("LC1_1.1 - Verify the Login Panel of \"Berater\".");
try {
//Accept All cookies
driver.findElement(By.className(property.getProperty("LiveContractCookies"))).click();
//Test case LC1_1.1 Open the given URL in browser (Aufruf der entsprechenden URL im browser)
boolean Homescreen = driver.findElement(By.name(property.getProperty("BeraterLoginPanelName1"))).isdisplayed();
Thread.sleep(3000);
Assert.assertTrue(Homescreen);
} catch (NoSuchElementException e) {
e.printstacktrace();
}
}
@Test
public void checkEntryFields() throws InterruptedException {
extentTest = extent.startTest("LC1_1.2 - Verify the Entry fields on Berater's login panel");
try {
driver.findElement(By.className(property.getProperty("LiveContractCookies"))).click();
WebElement username = driver.findElement(By.name(property.getProperty("username_fieldName")));
WebElement password = driver.findElement(By.name(property.getProperty("password_fieldName")));
username.click();
username.sendKeys("Test123");
password.click();
password.sendKeys("9876554");
Thread.sleep(1000);
System.out.println(username.getText());
String usnm = username.getAttribute("value");
String pass = password.getAttribute("value");
System.out.println("Something happening");
Assert.assertEquals("Test123",usnm);
Assert.assertEquals("98765",pass);
}
catch(Exception e){
e.printstacktrace();
}
}
@AfterMethod
public void tearDown(ITestResult result) {
if(result.getStatus() == ITestResult.FAILURE){
extentTest.log(LogStatus.FAIL,"Test Case Failed is" +result.getName());
extentTest.log(LogStatus.FAIL,"Test Case Failed is" +result.getThrowable());
String screenshotPath = Login.getScreenshot(driver,result.getName());
extentTest.log(LogStatus.FAIL,extentTest.addScreenCapture(screenshotPath));
}
else if(result.getStatus() == ITestResult.SKIP){
extentTest.log(LogStatus.SKIP,"Test Case Skipped is "+result.getName());
}
else if(result.getStatus() == ITestResult.SUCCESS){
extentTest.log(LogStatus.PASS,"Test Case Passed is "+result.getName());
}
extent.endTest(extentTest);
//extent.flush();
driver.quit();
//tempDriver.quit();
//tempDriver.quit();
}
@AfterTest
public void endReport() {
try{
extent.flush();
}
catch(Exception e){
e.getMessage();
}
//extent.close();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。