How to Set Browser Size in Selenium

Let’s learn, How can you set Browser Size in Selenium. Using Selenium WebDriver you can resize the Browser size. Selenium WebDriver allows resizing and maximizing window natively from its API. We use ‘Dimension’ class to resize the window.

 

Set Browser Size in Selenium

Let’s take the help of Selenium WebDrivers Dimension Class. Let’s open the facebook in the window size of 480*620.

 

In the above code, We are opening the FaceBook and we will get the default window size. Later on, We are creating the object 0f Dimension class. And pass the window dimensions in the constructor of Dimension Class, Later pass the Dimension class object to SetSize() method.

The above code opens the Facebook and later set the window size to 480*620 .

 

Set Browser Size in Chrome using ChromeOptions

 

That’s all, How you can Set Browser size in Selenium.

0 Comment

Leave a Reply