【问题标题】:What is the default size for `driver.manage().window().maximize()` for PhantomJs and HtmlUnit when using selenium-webdriver?使用 selenium-webdriver 时,PhantomJs 和 HtmlUnit 的`driver.manage().window().maximize()` 的默认大小是多少?
【发布时间】:2017-06-29 14:16:17
【问题描述】:

无头模式是在没有屏幕的电脑上使用的,那么 PhantomJS 和 HtmlUnit 是如何计算出最大尺寸的呢?

【问题讨论】:

    标签: selenium-webdriver phantomjs htmlunit maximize-window


    【解决方案1】:

    对于 HtmlUnit,(默认)值在 WebClientOptions 中

    private int screenWidth_ = 1024;
    private int screenHeight_ = 768;
    

    您可以将其更改为您喜欢的任何值:

    final WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED);
    webClient.getOptions().setScreenWidth(640);
    webClient.getOptions().setScreenHeight(480);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-18
      • 2018-03-29
      • 2016-04-25
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 2011-03-22
      • 1970-01-01
      相关资源
      最近更新 更多