How can I screen a full vertical size with exactly horizontal size?

人盡茶涼 提交于 2019-12-13 03:59:36

问题


I use a Selenium with the Ashot framework to make screenshots of the entire page

ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
WebDriver driver = new ChromeDriver(options);


Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).takeScreenshot(driver);

This shooting strategy works fine, I can get the full-sized screenshot. I received the screenshot with 1200 width x Full Size of my webpage, but I need to screenshot my webpage with different width sizes, for example, 1920xFullSize, 1280xFullSize etc. I tried to use Dimension to set exactly width:

Dimension d = new Dimension(1920,720 );
driver.manage().window().setSize(d);

but if I use a Dimension, the entire vertical size screenshot doesn't work and I receive 1920x720 image.

How can I screenshot 1920xFullSize, 1280xFullSize etc?


回答1:


I used the Selenium Grid in Docker container where I set the dimensions I need.



来源:https://stackoverflow.com/questions/52705346/how-can-i-screen-a-full-vertical-size-with-exactly-horizontal-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!