In this article, i will talk about How to handle proxy setting using selenium Webdriver?
Suggested Article to read
: What is Firefox profile, Need of Firefox profile?
If we try to access some secure application, we get proxy related error many times and manually we need to update the proxy there. But what if we are automating that secure application? Our automation code should handle this.
Some applications have also issues related to SSL certification error. We again do that manually by accepting & confirming the certificate. But again, what if this encounter when we automate application using selenium Webdriver?
In this post, let’s talk about how to handle proxy setting using selenium Webdriver?
While setting up the proxy, note that there are different values for network.proxy.type , which we need to set based on our need. Here are some values –
0 – Direct connection (or) no proxy.
1 – Manual proxy configuration
2 – Proxy auto-configuration (PAC).
4 – Auto-detect proxy settings.
5 – Use system proxy settings.
Below 4 steps explain how can we handle proxy setting via selenium
Step1: Create the FirefoxProfile object.
Step2: Set preference for network.proxy.type
Step3: Set preference for network.proxy.http
FirefoxProfile profile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(profile);
That’s it, this should handle the updated proxy in code.
Hope this helps. Drop your comments.