Resize browser window

0 votes

As pointed out in previous post (Maximize browser window), some websites implemented responsive design. You might want to execute some tests in smaller browser windows. Selenium WebDriver gives the ability to resize the browser window.

  @Test
  public void resizeWindow() {
    System.setProperty("webdriver.gecko.driver",
        FileUtil.findFileOnPath("mac/geckodriver"));
    final FirefoxDriver driver = new FirefoxDriver();

    driver.manage().window().setSize(new Dimension(400, 750));

    driver.get("http://www.selenium-in-action.io");
  }

See here a list of viewport sizes: http://viewportsizes.com/

Please follow and like us:
Follow by Email
Facebook
Google+
http://www.seleniuminaction.com/resize-browser-window/
Twitter
LinkedIn
Maximize browser window

Leave a Reply

Your email address will not be published. Required fields are marked *