Spaceman
Spaceman

Reputation: 1205

How to use socks proxy in webdriver's HTMLUNIT?

the code:

cap = DesiredCapabilities.HTMLUNITWITHJS
driver = webdriver.Remote("http://localhost:%i/wd/hub" % HTMLUNIT_PORT, cap)

tried doing this before initializing:

...
cap['proxy']['proxyType'] = 'manual'
cap['socksProxy'] = ip + ':' + str(port)
...

but it seems it didn't work - the IP remained unchanged.

How can I use socks proxy in webdriver AND htmlunit?

Upvotes: 0

Views: 842

Answers (1)

Spaceman
Spaceman

Reputation: 1205

That wasn't easy =(

Finally found it here: Running Selenium Webdriver with a proxy in Python

...
caps = webdriver.DesiredCapabilities.HTMLUNITWITHJS
PROXY = '127.0.0.1:9050'
caps['proxy'] = {
    "socksProxy":PROXY,
    "ftpProxy":PROXY,
    "sslProxy":PROXY,
    "noProxy":None,
    "proxyType":"MANUAL",
    "class":"org.openqa.selenium.Proxy",
    "autodetect":False
}

driver = webdriver.Remote(desired_capabilities=caps)
...

Upvotes: 1

Related Questions