Published November 23, 2017 by

How To Resize Browser Window Using Selenium WebDriver

To resize browser window to particular dimensions, we use ‘Dimension’ class to resize the browser window.

The below code opens the blog and then set the browser window size to 480*620 .
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ResizeBrowser {

public static void main(String args[]) {
System.setProperty("webdriver.gecko.driver", "C://Drivers//geckodriver.exe");
WebDriver driver = new FirefoxDriver();
// Create object of Dimensions class
Dimension d = new Dimension(480, 620);
// Resize the current window to the given dimension
    email this