How to Handle Proxy in Selenium Webdriver

Hello, Welcome to Selenium tutorials in this post we will see How to Handle Proxy in Selenium Webdriver.When you try to access some secure applications you will get proxy issues so many times. Until we do not set proxy, we cannot access the application itself.

Some application also has SSL certificate enabled or you can say as the secure site like banking, insurance company etc. To access these site you also have to handle certificates it is expired. I have one article which will discuss how to handle untrusted certificate in Selenium Webdriver.


How to Handle Proxy in Selenium Webdriver

You have now two option to handle this so based on your preferences you can use any one of this. I always consider the second approach.

1- Change the proxy setting manually and open default browser

2- Change the proxy setting using Webdriver code.


In this post, we will see the second approach

To handle proxy setting in Selenium we have a separate class called Proxy that is available inside org.openqa.selenium package


1-Create object of proxy class and set HTTP proxy or FTP proxy based on requirement

These are methods available for the proxy.


How to Handle Proxy in Selenium Webdriver
2 -Use DesiredCapability class to customize capability of browser and pass the proxy object.

3- While initiating browser pass capability object

Let’s implement the same-How to Handle Proxy in Selenium Webdriver

package blog;


Once you execute above program, proxy setting will be set in browser, you can check through browser setting

How to Handle Proxy in Selenium Webdriver


You can see the proxy settings has been added now.


Point- Let’s assume you have set of 100 test cases and now you have to make changes in all test right ? What you will do.

Ans- I always use the Base class concept of Selenium Webdriver which avoid this over work for me. I will also suggest you to apply the same in your code.


Thanks for visiting my blog. Please comment below if you finding any issue.

Keep in touch. Have a nice day 🙂


  1. manoj
  2. S. Shaikh
      • Rajan singh