How to resize current browser window in Selenium WebDriver with Java?

后端 未结 3 1541
无人及你
无人及你 2021-02-07 07:10

I need to resize the browser as 300x400 during executing the Selenium automated tests. How can I resize the browser window in Selenium WebDriver (aka, Selenium 2) with Java?

3条回答
  •  爱一瞬间的悲伤
    2021-02-07 07:57

    We can also use Chrome capability to resize the window.

    ChromeOptions options = new ChromeOptions();
    options.addArguments("window-size=800,480");
    
    DesiredCapabilities cap = DesiredCapabilities.chrome();
    cap.setCapability(ChromeOptions.CAPABILITY, options);
    

提交回复
热议问题