Can't maximize chrome window using Selenium
11,258
Solution 1
You can try it with start-maximized flag:
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['start-maximized']
}
}
Solution 2
I remember we had a similar issue - what we did is first set the size of the window and then maximize - don't remember exactly why did we apply this workaround, but it works for us:
browser.manage().window().setSize(1400, 900);
browser.manage().window().maximize();
Solution 3
According to your log - you do maximization twice. Maybe the first time it is maximized, and after the second try it is restored down to default size
Author by
Idan E
Updated on June 17, 2022Comments
-
Idan E almost 2 years
I've tried to maximize the window onPreapre by the command below:
browser.driver.manage().window().maximize();
But it doesn't maxmize the window and there's no error on selenium webdriver logs, actually it seems like the execute has been succeed -
Starting ChromeDriver 2.26.436421 (6c1a3ab469ad86fd49c8d97ede4a6b96a49ca5f6) on port 5814 Only local connections are allowed. 17:14:28.898 INFO - Done: [new session: Capabilities [{count=1, browserName=chrome, chromeOptions={args=[--no-sandbox, --test-type, --memory-metrics, --console, --crash-on-failure], prefs={download={directory_upgrade=true, default_directory=./Users/Idan/automation/tests/downloaded/, prompt_for_download=false}}}}]] 17:14:28.909 INFO - Executing: [set script timeout: 90000]) 17:14:28.910 INFO - Done: [set script timeout: 90000] 17:14:28.969 INFO - Executing: [maximise window]) 17:14:29.236 INFO - Done: [maximise window] 17:14:29.244 INFO - Executing: [maximise window]) 17:14:29.250 INFO - Done: [maximise window]