Last updated on August 1st, 2025 at 08:45 am
Selenium getSize() method
- getSize() method in selenium is part of WebDriver.Window interface.
- It is used when you want to get current working window dimensions.
- It will return height and width of current working browser window.
- Syntax : driver.manage().window().getSize();
Let us see how getSize() method works to get browser window dimension with example.
Selenium getSize() method example to get window size
package testPackage;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class getsizeExample{
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\chromedriver.exe");
WebDriver driver=new ChromeDriver();
//Get current window size dimension and print it in console.
Dimension size = driver.manage().window().getSize();
System.out.println(size);
}
}
In above given example, getsize() method will return height and width of current launched window and it will print it in console.

Hi, I’m Aravind — a seasoned Automation Test Engineer with over 17 years of hands-on experience in the software testing industry. I specialize in tech troubleshooting and tools like Selenium, Playwright, Appium, JMeter, and Excel automation. Through this blog, I share practical tutorials, expert tips, and real-world insights to help testers and developers improve their automation skills.In addition to software testing, I also explore tech trends and user-focused topics, including Snapchat guides, codeless test automation, and more.