2

I am trying to install my extension onto a remote machine with selenium. I have found a few snippets of code which would make this possible, but i cannot figure out how to get it to work.

What i have tried so far is this:

desired_cap = {'browser': 'Chrome', 'browser_version': '50.0', 'os': 'Windows', 'os_version': '10', 'resolution': '1366x768'}

def officialv1():
    url= 'loginurl'
        chop = webdriver.ChromeOptions()
        chop.add_extension('./Shoppingbuddy_v5.4.2.crx')
        driver = webdriver.Remote(command_executor=url, desired_capabilities=desired_cap, chrome_options=chop)

With chrome_options=chop out of place, because i do not know how to push this command to the remote browser aside with the command_executor and the desired_capabilities arguments.

I am stuck with telling my remote chrome to install the extension with the local file. So how do i tell my remote and active chrome, to install an extension which is in my local script folder.

I have found this question, which answers my question partially, but it does not tell me how to do it remotely.

Community
  • 1
  • 1
Maarten
  • 402
  • 5
  • 20

1 Answers1

2

Here is an example to add an extension with Chrome with a remote server:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_extension(r'C:\Downloads\Adblock-Plus_v1.11.crx')

capabilities = options.to_capabilities()
capabilities.update({'browser_version': '50.0', 'os': 'Windows', 'os_version': '10', 'resolution': '1366x768'})

driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", desired_capabilities=capabilities)
driver.get('http://stackoverflow.com/')

Note that it is preferable to set the Log level to WARNING to stop the server from writing the binary content of the extension in the log and console:

java -Dselenium.LOGGER.level=WARNING -jar selenium-server-standalone-2.53.0.jar
Florent B.
  • 41,537
  • 7
  • 86
  • 101