Wednesday, 3 November 2021

How to setup proxy with selenium.webdriver.Remote?

I'm trying to run selenium Remote via proxy.

This is the code I'm using:

proxy = '***.***.***.***:****'

options = selenium.webdriver.firefox.options.Options()
options.add_argument("--disable-gpu")

selenium.webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
    'autodetect': False,
    'class':      'org.openqa.selenium.Proxy',
    'ftpProxy':   proxy,
    'httpProxy':  proxy,
    'noProxy':    None,
    'proxyType':  'MANUAL',   # selenium.webdriver.common.proxy.ProxyType.MANUAL,
    'sslProxy':   proxy}

driver = selenium.webdriver.Remote(
        command_executor     = 'http://***.***.***.***:****/wd/hub',
        desired_capabilities = selenium.webdriver.common.desired_capabilities.DesiredCapabilities.FIREFOX,
        options              = options)

But I'm getting this error:

SessionNotCreatedException

Does anyone know what I'm doing wrong?

Any help will be appreciated!



from How to setup proxy with selenium.webdriver.Remote?

No comments:

Post a Comment