Mahdi
Mahdi

Reputation: 1035

Selenium does not open windows as maximized

I need to open the maximized page, but selenium does not work. It just opens the page usually.

from selenium.webdriver.chrome.options import Options    
options = Options()
options.add_argument("--start-maximized")
driver = webdriver.Chrome(executable_path=r'/Users/chromedriver', options=options)

Upvotes: 1

Views: 1906

Answers (5)

manymanymore
manymanymore

Reputation: 3128

And in C# it will be Driver.Manage().Window.Maximize();.

Upvotes: 0

Prophet
Prophet

Reputation: 33361

The -- shouldn't be there.
The correct syntax is:

from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

options = Options()
options.add_argument("start-maximized")
webdriver_service = Service('C:\webdrivers\chromedriver.exe')

driver = webdriver.Chrome(options=options, service=webdriver_service)

Upvotes: 0

Wunderbread
Wunderbread

Reputation: 1070

Per this post How to maximize chrome browser in default when using selenium in python you can try chrome_options.add_argument("--start-maximized") and depending on your version of chromedriver, it's worth reading through this post: How to maximize the browser window in Selenium WebDriver (Selenium 2) using C#?

driver.maximize_window() also seems to be an option to try.

Upvotes: 2

Tu Nguyen
Tu Nguyen

Reputation: 41

You should try this options.add_argument("window-size=1920,1080")

Upvotes: 1

craigb
craigb

Reputation: 1091

Do you mean --start-fullscreen?

Upvotes: 1

Related Questions