因此,我具有此功能,可以在测试失败的情况下捕获screenshot
:
public static String captureScreenshot(String testName) throws IOException {
File screenshotFile = takesScreenshot.getScreenshotAs(OutputType.FILE);
String path = "./screenshots/" + testName + ".png";
FileUtils.copyFile(screenshotFile, new File(path));
return path;
}
因此,此方法在Windows
上可以正常使用,但在Ubuntu
上似乎存在一些死锁,或者它卡在方法的第一行。
我一遍又一遍,甚至等待了几分钟,什么也没发生,只是卡住了。