Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

How to set the size of browser window using Selenium?

Category: Selenium WebDriver

To maximize the size of browser window, you can use the following piece of code:
driver.manage().window().maximize(); – To maximize the window

To resize the current window to a particular dimension, you can use the setSize() method. Check out the below piece of code:

System.out.println(driver.manage().window().getSize());
Dimension d = new Dimension(420,600);
driver.manage().window().setSize(d);

To set the window to a particular size, use window.resizeTo() method. Check the below piece of code:

((JavascriptExecutor)driver).executeScript(“window.resizeTo(1024, 768);”);

Leave a Reply

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