How to resize current browser window in Selenium WebDriver with Java?
You can get a reference to the current window with driver.manage().window()
. And the window
has a setSize()
method, so you could try
Dimension dimension = new Dimension(800, 600);
driver.manage().window().setSize(dimension)
If nothing works (to make tab in full screen only) for you, go for it:
driver.maximize_window()
where
driver = webdriver.Chrome(executable_path="D:\softwares\chromedriver.exe")
or could be any other webdriver locations.
For Responsive Design it's better if you don't use fixed data, in this case screen resolution - users need most often (cause it's much less prone to errors) :
_driver.manage().window().maximize();
or
_driver.manage().window().fullScreen();