java - Selenium 可以完全截取所有 Activity 桌面的屏幕截图吗?

标签 java linux selenium

selenium 是否可以不仅仅为浏览器中的页面截屏,而是为所有 Activity 桌面截屏?我只需要知道远程屏幕的尺寸。我们使用 Linux 和 Xvfb 进行 UI 测试

最佳答案

您可以使用 AWT 类 Robot 在 selenium webdriver 代码之间捕获屏幕。我不认为 selenium 有任何自己的 API 来捕获屏幕。

    BufferedImage screenBuffer = new Robot().createScreenCapture(
               new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()) );
    File file = new File("MyScreen.jpg");
    ImageIO.write(screenBuffer, "jpg", file); 

关于java - Selenium 可以完全截取所有 Activity 桌面的屏幕截图吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32047278/

相关文章:

python - 导入错误 : No module named 'sqlite3'

java - 如何根据 TestNG + Selenium WebDriver 中的运行结果选择下一个 @Test 方法?

javascript - 如何通过 Python 使用 GhostDriver 处理警报?

java - Spring 。访问webapp\resources目录

java - 有没有办法使用 Hibernate 只从对象中获取更改的列?

linux - Centos需要很长时间才能解析本地网络附近的服务器

python - Selenium 远程网络驱动程序错误

java - RMI中的rmic是什么?

java - 搭建游戏!项目与maven

c++ - 使用 fork/execvp 和系统调用的区别