Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I control Chromedriver open window size?

I'm using Selenium WebDriver for automation and I'm using Chromedriver.

I have noticed that when my driver runs and opens the chrome browser, it opens the browser with a strange size. I tried to fixed it but in vain.

Does anybody know how can I change it?

like image 840
Nimrod_G Avatar asked Apr 30 '14 06:04

Nimrod_G


People also ask

How do I make Chrome open in maximized state?

Use the ChromeOptions class An alternate method that can maximize the Chrome window is to use the ChromeOptions class. This method informs the Chrome browser explicitly to launch in maximized mode.

How do I change the zoom size in Chrome using Selenium?

In Selenium, this can be easily achieved. In this article, I will show you two methods on how to Zoom In and Zoom Out in Selenium WebDriver. Manually, we have to press CTRL+ADD to do Zoom In and we have to press CTRL+SUBTRACT to do zoom out.


2 Answers

Python

Drivers

chrome = 57.0.2987.133 chromedriver = 2.27.440174 

Code:

from selenium.webdriver.chrome.options import Options  chrome_options = Options() chrome_options.add_argument("--window-size=1920,1080") driver = Chrome(chrome_options=chrome_options) 
like image 64
Yonatan Kiron Avatar answered Oct 05 '22 00:10

Yonatan Kiron


Use this for your custom size:

driver.manage().window().setSize(new Dimension(1024,768)); 

you can change your dimensions as per your requirements.

like image 41
nitin chawda Avatar answered Oct 05 '22 01:10

nitin chawda