when i use object.manage().window().maximize(); method the window is not maximizing . The following error shown
Starting ChromeDriver 2.29.461591 (62ebf098771772160f391d75e589dc567915b233) on port 24144
Only local connections are allowed.
Apr 29, 2017 10:04:02 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.04 seconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'NBW7BANINFOS6', ip: '192.168.0.2', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.29.461591 (62ebf098771772160f391d75e589dc567915b233), userDataDir=C:\Users\ADMINI~1\AppData\Local\Temp\scoped_dir10152_31085}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=57.0.2987.133, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: 824bcb85e7d4e2ad25f1600b97d66907
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:694)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:925)
at vaishu.Mounika.main(Mounika.java:16)
please tell me solution.
2 Answers 2
To work with latest Chrome drivers 2.29 you need to maximize the window using Chrome Options class as follows:
System.setProperty("webdriver.chrome.driver", "C:\\Utility\\BrowserDrivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("--enable-automation");
options.addArguments("test-type=browser");
options.addArguments("disable-infobars");
WebDriver driver = new ChromeDriver(options);
driver.navigate().to("http://gmail.com");
Let me know if this answers your Question.
-
thank you its working , but it is very lengthy . manage().window().maximize() why it is not working. if u know please tell and once again thank you.anusha raju– anusha raju2017年05月01日 15:53:07 +00:00Commented May 1, 2017 at 15:53
-
yes u said perfect answer. & my question is manage().window().maximize() method should work to maximize the window. but it is not working on neither chrome nor mozilla why???? Thanks.anusha raju– anusha raju2017年05月01日 16:05:41 +00:00Commented May 1, 2017 at 16:05
-
I think I have already answered your Question in my Answer itself. Mozilla still works with
driver.manage().window().maximize()
Thanks.undetected Selenium– undetected Selenium2017年05月01日 16:09:06 +00:00Commented May 1, 2017 at 16:09 -
oh sorry ,seen. shall i ask u another question?? Thanks.anusha raju– anusha raju2017年05月01日 16:12:02 +00:00Commented May 1, 2017 at 16:12
-
@anusharaju Yes, you canundetected Selenium– undetected Selenium2017年05月01日 16:14:21 +00:00Commented May 1, 2017 at 16:14
Some times maximize window doesn't work with old version of web driver . So solution is to update the web driver and give the update driver path in program .
-
1I'm afraid this answer isn't substantially different from the accepted answer. Could you clarify how it is?2018年12月12日 07:28:03 +00:00Commented Dec 12, 2018 at 7:28