javagoogle-chromeautomationwebdriverashot

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


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?


Solution

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