How to set the size of browser window using Selenium?

To maximize the size of browser window, you can use the following piece of code: 


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

Dimension d = new Dimension(500, 600);

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);");