I am using the GhostDriver as the WebDriver implementation in a Java-based project. I want to take snapshots of the pages. The default page size is kind of awkward, so I want to control the page size of the snapshots. However, I can't find any examples from Google. So, can someone tell me how? Thank you very much.
Asked
Active
Viewed 6,642 times
3
1 Answers
18
Have you tried setSize()
method 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");

Yi Zeng
- 32,020
- 13
- 97
- 125
-
3It works! Many thanks. :-) BTW, just to make it clearer, Dimension = org.openqa.selenium.Dimension as in `new Dimension(1920, 1080)` – JBT Feb 13 '14 at 01:55
-
It is not working for me. Could you please let me know is there any other option – QAMember Sep 20 '17 at 06:30