1

I am using selenium webdriver in python scripts. I want to change proxy settings to vpn from python before visiting any website so that when visit any website through webdriver they will detect according to vpn ip address.

Can anybody please help me to do this. Thanks in advance for your help.

Mac Proxy Settings

Rafayet Ullah
  • 1,108
  • 4
  • 14
  • 27
  • I solved the issue by changing Firefox Profile settings. It is not doing the exact same thing. But enough for my requirement. You may also try this. http://stackoverflow.com/a/38168865/5409601 – Rafayet Ullah Jul 03 '16 at 10:22

1 Answers1

0

As you are using python binding, you need to use the remote object to set the proxy.

the other way is to change the python binding code itself.

Following code will change the proxy

from selenium import webdriver

PROXY = "localhost:8080"

# Create a copy of desired capabilities object.
desired_capabilities = webdriver.DesiredCapabilities.INTERNETEXPLORER.copy()
# Change the proxy properties of that copy.
desired_capabilities['proxy'] = {
    "httpProxy":PROXY,
    "ftpProxy":PROXY,
    "sslProxy":PROXY,
    "noProxy":None,
    "proxyType":"MANUAL",
    "class":"org.openqa.selenium.Proxy",
    "autodetect":False
}

# you have to use remote, otherwise you'll have to code it yourself in python to 
# dynamically changing the system proxy preferences
driver = webdriver.Remote("http://localhost:4444/wd/hub", desired_capabilities)
Gaurang Shah
  • 11,764
  • 9
  • 74
  • 137