Unable to zoom chrome window with Selenium

I tried to maximize the onPreapre window with the following command:

browser.driver.manage().window().maximize(); 

But this does not maximize the window, and there are no errors in the selenium webdriver logs, it actually seems that the execution was successful -

 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] 
+5
source share
5 answers

You can try with the start-maximized flag:

 capabilities: { 'browserName': 'chrome', 'chromeOptions': { 'args': ['start-maximized'] } } 
+6
source

I remember that we had a similar problem - we first set the window size and then maximized it - don’t remember why we applied this workaround, but it works for us:

 browser.manage().window().setSize(1400, 900); browser.manage().window().maximize(); 
+3
source

According to your journal, you do maximization twice. Perhaps the first time it will be maximum, and after the second attempt it will be restored to the default size

+2
source

You can use javascript for this.

 ((IJavaScriptExecutor)browser).ExecuteScript("window.resizeTo(x, y);"); 

'x' and 'y' depend on your screen resolution.

0
source

The best way to maximize a chrome application is through JavaScript. Try the following:

 //Maximizing Chrome App Window. JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("window.resizeTo(1366, 768);"); 

Change the parameters 1366, 768 in accordance with the settings / settings of your monitor.

0
source

Source: https://habr.com/ru/post/1262466/


All Articles