Not able to maximize Chrome Window in headless mode

Since you’re running tests in a headless mode, there is no active browser window available. As such your

   driver.driver.manage().window().maximize()

would always fail in such situations because the driver doesn’t know which window to maximize since there aren’t any available.

You can either follow what @DebanjanB has mentioned or you can start the headless browser with a specific screen size like 1440×900 etc, doing something like this

 driver.manage().window().setSize(new Dimension(1440, 900));

Leave a Comment