简体   繁体   English

Chromedriver最大化问题

[英]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. 我正在尝试使用selenium python(使用下面的代码)最大化我的chrome浏览器,并且每次selenium打开浏览器时它都不会最大化整个窗口。它最大化只有一半的屏幕,“data:,”已填充在地址栏上。

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 . ChromeDriver中存在一个特定于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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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