Java – how to set the screen / window size when using ghostdriver

I use ghostdriver as webdriver implementation in Java - based projects I want to take a snapshot of the page The default page size is a bit clumsy, so I want to control the page size of the snapshot But I can't find any examples of Google So, how about someone tell me? thank you very much.

Solution

Have you ever tried webdriver Window's setsize() method? Here is the document

// 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("https://stackoverflow.com/questions/21743350/how-to-set-screen-window-size-when-using-ghostdriver");
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>