Thursday, February 14, 2019

py0010 : Firefox not opening Websites which are in Tunnel/Proxy

If your system has implemented with proxy or tunnel and you want to open a web link (which are in tunnel or in proxy)
note* generally these kind of websites not worked on internet, but the firefox leaunched by Selenium/python using Geckodriver is open with internet without any proxy setting given in your system. So you have add some lines of code in your .py file before Geckodriverr called so that it will open firefox with system proxy settings.

#Add proxy IP Address
proxy = "***.***.***.***"
#Add proxy port
port = int("****")

cap = DesiredCapabilities().FIREFOX
cap["marionette"] = True

profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", proxy)
profile.set_preference("network.proxy.http_port", port)
profile.set_preference("network.proxy.ssl", proxy)
profile.set_preference("network.proxy.ssl_port", port)
profile.update_preferences()

Related/Helpful Links:
py0005 : selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities
py0004 : Begginner error, Open Firefox

No comments:

Post a Comment

web stats