Я запускаю свои тесты селена через Jenkins на браузере Firefox без браузера на Cent OS. Я написал код для снятия скриншотов при сбое, который отлично работает в моей локальной среде Windows, но когда я запускаю тот же скрипт с помощью Jenkins на CentOS, снимок экрана составляет 0 байт.при запуске тестов selenium через jenkins на безголовом браузере firefox скриншоты взяты из 0 байтов
Ниже приведен код Java для захвата скриншота :
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
public class Screen_Capture {
public static void takeDesktopScreenshot(WebDriver driver,String dateFormat,String fileFormat,String screenPath){
File src=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
try{
SimpleDateFormat s=new SimpleDateFormat(dateFormat);
String d=s.format(new Date());
FileUtils.copyFile(src, new File(screenPath+d+"."+fileFormat));
}
catch (Exception e) {}
}
}
скриншоты захватывается на Test Failure:
@Override
public void onTestFailure(ITestResult arg0) {
Screen_Capture.takeDesktopScreenshot(driver,dateFormat,fileFormat,screenPath);
log.error("Test Case Failed");
}
The Images saved on Jenkins Workspace is blank(0 bytes)
[Screen File Size is 0 Bytes][1]
Please help me to overcome this issue.
I am also attaching my Build Environment Configuration on Jenkins:
[Build Environment Configuration on Jenkins][2]
[1]: https://i.stack.imgur.com/NBNUD.png
[2]: https://i.stack.imgur.com/qMxPq.png