Reputation: 345
I am trying to run a Chrome webdriver with extension and it is working on non remote setup, but as soon as I set up remote webdriver, it fails to start. Here is what system outputs:
selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new
session. Error while creating session with the driver service. Stopping driver
service: Could not start a new session. Response code 500. Message: unknown error:
failed to wait for extension background page to load: chrome-
extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/_generated_background_page.html
from unknown error: page could not be found: chrome-
extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/_generated_background_page.html
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ec5758b8a125', ip: '172.17.0.2', os.name: 'Linux', os.arch:
'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.13'
Driver info: driver.version: unknown
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: 'ec5758b8a125', ip: '172.17.0.2', os.name: 'Linux', os.arch:
'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.13'
Driver info: driver.version: unknown
Here is my driver.py file:
def initialize():
global instance
options = webdriver.ChromeOptions()
prefs = {'download.default_directory': '/driver/extensions'}
options.add_experimental_option('prefs', prefs)
options.add_extention('path/to/extension')
options.add_argument('--headless')
instance =
webdriver.Remote('http://localhost:4444/wd/hub', DesiredCapabilities.CHROME,
options=options)
# instance = webdriver.Chrome(options=options) # this is working
instance.implicitly_wait(2)
return instance
Upvotes: 1
Views: 622
Reputation: 2988
To make Chrome webdriver be able to run with an extension it should be non-headless.
This config should be removed:
options.add_argument('--headless')
Reference
https://bugs.chromium.org/p/chromium/issues/detail?id=706008
Upvotes: 1