1

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!

JPN
  • 632
  • 12
  • 24
  • 1
    Can you please provide the full Exception text. – D-E-N Nov 03 '21 at 19:19
  • Can you elaborate on your remote selenium setup. I.E. is it a selenium grid setup using official docker images ? Which version of selenium grid are you setting up v3 or v4? What version of selenium is your project, I'm assuming it is 3.141.59 or similar as you are still using Desired Capabilities? If you are running selenium grid, is that external to your test project (i.e. Jenkins)? Where is the proxy in your setup ? If external, what are you trying to achieve? Are you trying to reach the selenium grid via a proxy, or for the browser to test target via a proxy? The info above is not enough – djmonki Nov 04 '21 at 14:17
  • this [link](https://stackoverflow.com/questions/40172788/unable-to-create-new-remote-session) will help you out – UnkownReality Nov 09 '21 at 15:56

1 Answers1

0

This works.

options = selenium.webdriver.ChromeOptions()
options.add_argument("-incognito");
options.add_argument(f'--proxy-server={proxy}')
JPN
  • 632
  • 12
  • 24