Solve chrome running error unknown error: cannot get automation extension

phenomenon

Today, I changed the default browser to chrome. As a result, an error was reported as soon as the script was run. The specific error message is as follows.

FAILED CONFIGURATION: @BeforeClass beforeClass
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=59.0.3071.115)
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.12 seconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'admin2-PC', ip: '10.2.16.2', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_17'
Session ID: a2cffef46bdbde6af4e7ec75998d2bd9
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=C:\MyTemp\scoped_dir6928_24278, chromedriverVersion=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9)}, networkConnectionEnabled=false, unexpectedAlertBehaviour=, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=59.0.3071.115, pageLoadStrategy=normal, takesHeapSnapshot=true, databaseEnabled=false, cssSelectorsEnabled=true, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, hasTouchScreen=false, applicationCacheEnabled=false, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:825)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:166)
    at org.testng.internal.TestMethodWorker.run (TestMethodWorker.java: 105 )
    at org.testng.TestRunner.privateRun (TestRunner.java: 744 )
    at org.testng.TestRunner.run (TestRunner.java: 602 )
    at org.testng.SuiteRunner.runTest (SuiteRunner.java: 380 )
    at org.testng.SuiteRunner.runSequentially (SuiteRunner.java: 375 )
    at org.testng.SuiteRunner.privateRun (SuiteRunner.java: 340 )
    at org.testng.SuiteRunner.run (SuiteRunner.java: 289 )
    at org.testng.SuiteRunnerWorker.runSuite (SuiteRunnerWorker.java: 52 )
    at org.testng.SuiteRunnerWorker.run (SuiteRunnerWorker.java: 86 )
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
    at org.testng.TestNG.runSuites(TestNG.java:1144)
    at org.testng.TestNG.run(TestNG.java:1115)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

 

After searching for a long time, I found out that my version of chromedriver.exe was too old, and it was fine after upgrading to the latest version. There is a small problem here. The version rule of Selenium is the major version number + the minor version number, so:

  • 2.1 is much earlier than 2.10
  • 2.9 is earlier than 2.10

The chronological order of each version, from newest to oldest, is:

  • 2.19>2.10>2.9>2.1
    http://selenium-release.storage.googleapis.com/index.html
  • Chrome Driver:
    http://chromedriver.storage.googleapis.com/index.html
  • PhantomJS Driver:
    http://phantomjs.org/download.html


Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *