How to handle proxy authentication using Selenium Webdriver

0 votes
May 28, 2019 in Selenium by Rajat
2,804 views

1 answer to this question.

0 votes

Hi Rajat, you can set HTTP proxy with Selenium Webdriver using this code snippet:

import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class ProxyDemo {

 public static void main(String[] args) {


  // Create proxy class object
  Proxy p=new Proxy();


  // Set HTTP Port to 7777
  p.setHttpProxy("localhost:7777");

  // Create desired Capability object
  DesiredCapabilities cap=new DesiredCapabilities();


  // Pass proxy object p
  cap.setCapability(CapabilityType.PROXY, p);


  // Open  firefox browser
  WebDriver driver=new FirefoxDriver(cap);

  // write your normal automation script here

 }


}
answered May 28, 2019 by Abha
• 28,040 points

Related Questions In Selenium

+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,520 points
5,589 views
0 votes
1 answer

How to handle Pop-up in Selenium WebDriver using Java

Actually, its pretty simple. Use this code ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,520 points
8,332 views
+2 votes
3 answers

How can we handle authentication popup in Selenium WebDriver using Java

1) By passing user credentials in URL. String ...READ MORE

answered Aug 30, 2020 in Selenium by Sri
• 3,050 points
22,187 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
5,335 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,050 points
6,016 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
3,727 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,050 points
4,534 views
+1 vote
1 answer
0 votes
1 answer

How to print all google suggestions for a keyword using Selenium Webdriver?

Hello Cherry, below is the automation script ...READ MORE

answered May 22, 2019 in Selenium by Abha
• 28,040 points
2,158 views