Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chromedriver maximize issue

I'm new to this forum as well as to programming and selenium. I'm trying to maximize my chrome browser using selenium python(using the below code) and everytime selenium opens the browser it would not maximize the whole window.It maximizes only half the screen with "data:," already filled on the address bar.

self.driver = webdriver.Chrome() 
self.driver.maximize_window()

I also tried

options=webdriver.ChromeOptions()
options.add_argument("--start-maximized")
driver=webdriver.Chrome(chrome_options=options)

but doesn't help

Screenshot of the browser

like image 306
premonition Avatar asked Dec 19 '22 17:12

premonition


2 Answers

Just looked at my code and noticed that my import is

 from selenium.webdriver.chrome.options import Options

And the rest of the code is

 options = Options() 
 options.add_argument("--start-maximized") 
 driver=webdriver.Chrome(chrome_options=options) 

This does work

like image 133
middlestump Avatar answered Dec 21 '22 10:12

middlestump


There is an open issue in ChromeDriver which is specific to Mac OS X.

What I remember helped was to first set the dimensions explicitly and then maximize:

driver.set_window_size(1200, 800)
driver.maximize_window()
like image 22
alecxe Avatar answered Dec 21 '22 09:12

alecxe