简体   繁体   中英

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

浏览器的屏幕截图

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

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM