Selenium: Not able to take complete page screenshot using aShot library(Selenium:无法使用 aShot 库获取完整的页面截图)
问题描述
我正在尝试使用 Firefox gecko
驱动程序和
driver.get("https://google.com");截图 fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);ImageIO.write(fpScreenshot.getImage(),"JPEG",new File("FullPageScreenshot.jpg"));
查看了很多变体,但没有任何效果.有趣的是,当我尝试使用旧的 Firefox 版本(46)时,我可以在没有任何第三方库的情况下截取完整的屏幕截图.我正在尝试使用最新的 firefox 并拥有完整的屏幕截图功能.
有什么帮助吗?
试试:
Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(ShootingStrategies.scaling(1.75f), 1000)).takeScreenshot(driver);
其中 1.75f 是设备像素比(您可以在浏览器控制台中运行 window.devicePixelRatio;
来找到它).如果仍然没有捕获全屏,请将其更改为 2f
Am trying to take the complete page screenshot both horizontally and vertically using Firefox gecko
driver and aShot Library.
However, the results are not as expected. Take a look:
driver.get("https://google.com");
Screenshot fpScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
ImageIO.write(fpScreenshot.getImage(),"JPEG",new File("FullPageScreenshot.jpg"));
Looked into a lot of variants but nothing is working. Interestingly, when I try using old firefox version (46), I am able to take full screenshot without any third party library. Am trying to use latest firefox and have full screenshot functionality.
Any help?
Try:
Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(ShootingStrategies.scaling(1.75f), 1000)).takeScreenshot(driver);
where 1.75f is device pixel ratio (you can run window.devicePixelRatio;
in browser console to find it).
If it's still not capturing full screen, change it to 2f
这篇关于Selenium:无法使用 aShot 库获取完整的页面截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Selenium:无法使用 aShot 库获取完整的页面截图
基础教程推荐
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01