Selenium: Python/Chrome "cannot get automation extension" during screenshot.

Created on 7 Mar 2017  路  5Comments  路  Source: SeleniumHQ/selenium

Meta -

OS:
MacOS 10.12.3
Selenium Version:
ChromeDriver 2.27
selenium-3.0.2 via pip3
Browser:
Chrome 57.0.2987.88

Python3 Script to reproduce:

import selenium.webdriver as webdriver
import time

browser = webdriver.Chrome()
browser.get("https://google.com")
time.sleep(2)
browser.save_screenshot("test.png")
browser.quit()

Result:

$ python3 wd_test.py 
Traceback (most recent call last):
  File "wd_test.py", line 7, in <module>
    browser.save_screenshot("test.png")
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 798, in get_screenshot_as_file
    png = self.get_screenshot_as_png()
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 817, in get_screenshot_as_png
    return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 827, in get_screenshot_as_base64
    return self.execute(Command.SCREENSHOT)['value']
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: 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.88)
  (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.12.3 x86_64)

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x10e89b588>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 173, in __del__
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 149, in stop
  File "/usr/local/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 120, in send_remote_shutdown_command
ImportError: sys.meta_path is None, Python is likely shutting down

"cannot get automation extension" has been reported many times over the years. Not necessarily anywhere useful to the selenium developer team though - https://www.google.com/search?q=%22cannot+get+automation+extension%22

If you change to Firefox it works as expected (no exception thrown)

Most helpful comment

Chromedriver version 27 only Supports Chrome v54-56
Please log chromedriver issues with the chromedriver project.

https://sites.google.com/a/chromium.org/chromedriver/help

All 5 comments

Chromedriver version 27 only Supports Chrome v54-56
Please log chromedriver issues with the chromedriver project.

https://sites.google.com/a/chromium.org/chromedriver/help

Can we maybe have a URL added to the error message, like some other WebDriver errors ?

@paul-hammant the error contents is coming from chromedriver

I'm talking about catching that in WebDriver and decorating with an additional piece of information [1] (the URL) before throwing it.

Then a range of choices for the user are detailed: a) Upgrade chromedriver, b) cajole Chromium team into shipping a new one, c) use your package manager to upgrade

[1] http://docs.seleniumhq.org/docs/cannot_get_automation_extension.html#v2.27.440174

It is an unknown error type, we won't know what the issue is and this one is specific to chromedriver not all webdrivers

Was this page helpful?
0 / 5 - 0 ratings