linux - 无法在 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 触发我的测试。
谢谢你的帮助。
解决方案
推荐阅读
- python - 使用 tf.Dataset 加载和预处理数据的问题
- node.js - 在 Node.js 中编写脚本时如何使用“cd”移动到另一个文件夹?
- r - 根据 R 中的组创建 ggplot2 图例?
- python - 在opencv(python)中检测这两个对象之间碰撞的最佳方法是什么?
- java - Spring Boot 中的接口注解
- typescript - Nativebase React Native 为什么我不能在输入中传递数字
- react-native - 我在 Google Play 上发布的 Expo App 仍然安装旧版本
- c++ - 在检查它是否是素数之前检查数字是否是偶数(当然> 2)会提高性能吗?
- mysql - C - 替代使用 snprintf 来准备 MySQL 语句?
- wso2 - 在 wso2 API-Management 中,如何只将网关与另一个 vm 分开?