How to set screen / window size when using GhostDriver

I am using GhostDriver as an implementation of WebDriver in a Java project. I want to take snapshots of pages. The default page size is awkward, so I want to control the page size of the snapshots. However, I can not find examples from Google. So can someone tell me how? Thank you very much.

+3
source share
1 answer

Have you tried the method setSize()from WebDriver.Window? Here is the documentation.

// untested Java code, only provides the logic
// please debug and refer to the documentation

import org.openqa.selenium.Dimension;

WebDriver driver = new PhantomJSDriver();

driver.manage().window().setSize(new Dimension(1920, 1080));
// or driver.manage().window().maximize();

driver.get("http://stackoverflow.com/questions/21743350/how-to-set-screen-window-size-when-using-ghostdriver");
+17
source

All Articles