使用GhostDriver时如何设置屏幕/窗口大小 [英] How to set screen/window size when using GhostDriver
本文介绍了使用GhostDriver时如何设置屏幕/窗口大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将GhostDriver用作基于Java的项目中的WebDriver实现.我想拍摄页面快照.默认页面大小有点尴尬,因此我想控制快照的页面大小.但是,我找不到Google提供的任何示例.那么,有人可以告诉我如何吗?非常感谢.
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.
推荐答案
您是否尝试过WebDriver.Window
中的setSize()
方法? 此处是文档.
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");
这篇关于使用GhostDriver时如何设置屏幕/窗口大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文