Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Maximize window in chrome using webDriver (python)

Is there a way to maximize the chrome browser window using python selenium WebDriver?

Note: I am using Chrome Driver 23.0 Any solution on this would be greatly appreciated!

like image 903
Naveen Subramani Avatar asked Aug 31 '12 08:08

Naveen Subramani


People also ask

How does Selenium Webdriver maximize Chrome window?

To maximize browser in Selenium, you need to call the maximize() Selenium command to maximize window interface of the driver class. void maximize() – This method is used to maximize the current browser.

How do you maximize a window in Python?

We can maximize or minimize a browser window using Selenium webdriver in Python. We can use the method maxmize_window to maximize a browser. We can use the method minimize_window to minimize a browser. Finally, Again, to get the size of the browser, we can use the method get_window_size.


2 Answers

You could use ChromeOptions and set suitable argument:

options = ChromeOptions() options.add_argument("--start-maximized") driver = ChromeDriver(options) 
like image 100
Janek Królikowski Avatar answered Oct 09 '22 02:10

Janek Królikowski


Nothing worked for me except:

driver.set_window_size(1024, 600) driver.maximize_window() 

I found this by inspecting selenium/webdriver/remote/webdriver.py. I've never found any useful documentation, but reading the code has been marginally effective.

like image 20
Tom Rose Avatar answered Oct 09 '22 02:10

Tom Rose