6

I am stuck with a very unusual kind of error thrown by Chrome Browser

When I try to do maximize chrome with below line of code

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

I am getting below error

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.110)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.05 seconds

By going through this example I did the below things

1. Updated Chrome driver to latest i.e 2.28 for my Chrome version 
   57.0.2987.110 (64-bit)
2. uninstalled and re-installed Chrome
3. did a project build up in Eclipse even created a new workspace

but nothing helped so I used

    ChromeOptions options = new ChromeOptions();
    options.addArguments("start-maximized");
    driver = new ChromeDriver();

it worked and Chrome driver showed no error but whenever I execute some piece of code like filling a form or clicking some button after that it still throws the above error after some time.

halfer
  • 19,471
  • 17
  • 87
  • 173
eduliant
  • 2,690
  • 4
  • 22
  • 36

2 Answers2

6

In general the reason you see WebDriverException: unknown error: cannot get automation extension can be numerous. The two most common cases to see this exception is :

  1. Mismatch between chromedriver binary and Chrome Browser binary versions. Solution : Follow the ChromeDriver Release Notes
  2. Using driver.manage().window().maximize(); to maximize the Chrome Browser. Solution : Use ChromeOptions.addArguments("start-maximized"); to maximize the Chrome Browser.

As per your question the exception seems to be coming from one of the above cases.

Try out the following steps:

  1. Kill all the chromedriver instances running in your windows Task Manager.
  2. Use CCleaner tool to wipe out all the OS chores.
  3. Clean all the projects in Eclipse.
  4. Reboot your system once.
  5. Provide the following options to start your Chrome browser:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("test-type");
    options.addArguments("start-maximized");
    options.addArguments("disable-infobars");
    options.addArguments("--disable-extensions"); 
    driver = new ChromeDriver(options);
    

Your program should work with latest chrome driver 2.28 & Chrome Version 57.0.2987.110 (64-bit). Let me know if this helps you.

undetected Selenium
  • 151,581
  • 34
  • 225
  • 281
  • what is the error you are getting now? may I help you out? – undetected Selenium Mar 27 '17 at 14:05
  • same error brother,form last two weeks i am facing this error earlier all scripts were running fine – eduliant Mar 27 '17 at 14:43
  • Updated my Answer. Please check and let me know if it works.Thanks. – undetected Selenium Mar 27 '17 at 14:48
  • Thanks bro this time its working as per expectation can you please tell me why we are using so much of chrome option parameters and passing it to the chrome instance,i mean is there any architectural update in chrome 2.28 – eduliant Mar 27 '17 at 15:07
  • Where and how do I need to provide these options? Your code looks like Java. – mcv Jul 05 '17 at 15:11
  • @mcv Yes, it's Java. Which binding are you using? – undetected Selenium Jul 05 '17 at 15:14
  • My setup is all node.js. I managed to get it working by forcing version 2.30 with `webdriver-manager start --versions.chrome 2.30`. Not sure why it didn't use that version automatically. My error started after I updated OS X from Lion to Sierra. – mcv Jul 06 '17 at 23:29
3

I had the same issue before, remember fixing it by adding this:

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("no-sandbox");
//Fix for cannot get automation extension
chromeOptions.addArguments("disable-extensions");
chromeOptions.addArguments("--start-maximized");
Ranjith's
  • 4,068
  • 5
  • 21
  • 38