At times during automation we may be required to test an application with some specific browser window dimensions. In this post we will be studying how to resize a browser to an exact dimension.
In order to achieve this, we will use the setSize() method which takes the Dimension object as input. The Dimension object has width and height integer fields. Hence, we can set the width and height of the browser by calling the setSize method with the required dimensions of the browser window.
During automation its one of the best practices to maximize the browser in the initial phases (or in the BeforeTest method in case you are using TestNG as the testing framework). Selenium provides direct command to maximize the browser window. The following command is use to maximize the browser window.