How to handle proxy authentication using Selenium Webdriver?

0 votes
May 28, 2019 in Selenium by Rajat
1,968 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
• 27,930 points

Related Questions In Selenium

0 votes
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,510 points
3,961 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,510 points
7,092 views
+2 votes
2 answers

How can we handle authentication popup in Selenium WebDriver using Java

You can use below code for selenium ...READ MORE

answered Jun 21 in Selenium by TEJAS KIRAN RATHI
16,312 views
0 votes
1 answer
0 votes
1 answer

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,510 points
3,103 views
0 votes
1 answer
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
2,349 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,890 points
2,497 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
• 27,930 points
1,121 views