0

My question is about setting proxy in selenium coding in python (3.6) for IE browser.

from selenium import webdriver

PROXY = "94.56.171.137"
PORT = 8080

base_url = "https://google.com"

desired_capability = webdriver.DesiredCapabilities.INTERNETEXPLORER
desired_capability['proxy'] = {
    "proxyType": "manual",
    "httpProxy": PROXY,
    "httpProxyPort": PORT,
    "ftpProxy": PROXY,
    "ftpProxyPort": PORT,
    "sslProxy": PROXY,
    "sslProxyPort": PORT,
    "class":"org.openqa.selenium.Proxy",
}

driver = webdriver.Ie(executable_path='C:\\tmp\\IEDriverServer',capabilities=desired_capability)
driver.get(base_url)

I am getting the below Error message -

<p>The following error was encountered while trying to retrieve the URL: <a href="http://127.0.0.1:54684/session">http://127.0.0.1:54684/session</a></p>

I took the reference from the below -

https://stackoverflow.com/questions/45949274/setting-proxy-in-selenium-in-python-for-firefox-geckodriver?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

And its working fine in FireFox browser but I am not able to run in IE browser.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Sahu
  • 1
  • 1

1 Answers1

0

Seems you were pretty close. As you are on Windows OS you need to add the extension of the WebDriver Binary (i.e. .exe). Additionally, put the absolute path of the IEDriverServer within single quotes (i.e. '') along with File separator as single front slash (i.e. \) preceeded by the raw (i.e. r) switch as follows:

driver = webdriver.Ie(executable_path=r'C:\tmp\IEDriverServer.exe', capabilities=desired_capability)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352