首页 > 解决方案 > 无法在 Ubuntu (AWS) 上截取屏幕截图图像(Selenium 测试),但相同的代码可以在 Windows 机器上运行?

问题描述

目前,我正在尝试在发生故障时截取图像(在 Ubuntu AWS 实例上运行测试)。

我的代码:

WebDriver augmentedDriver = new Augmenter().augment(getDriver());
File screenshotFile = ((TakesScreenshot)augmentedDriver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile, new File("/home/ubuntu/Desktop/efesfe.png"));

还尝试在 ubuntu 桌面上创建一个文本文件,但它也不起作用:

File fout = new File("/home/ubuntu/Desktop/myOutFile.txt");
FileOutputStream fos = new FileOutputStream(fout);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
bw.write("Write somthing to the file ...");
bw.newLine();
bw.close();

请注意,我正在通过托管在 Ubuntu 实例上的 Jenkins 触发我的测试。

谢谢你的帮助。

标签: linuxamazon-web-servicesseleniumubuntujenkins

解决方案


推荐阅读