How to handle proxy authentication using Selenium Webdriver

0 votes
May 28, 2019 in Selenium by Rajat
4,067 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,140 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,500 points
8,358 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 6, 2018 in Selenium by nsv999
• 5,500 points
10,557 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 31, 2020 in Selenium by Sri
• 3,190 points
29,073 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,500 points
13,674 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,190 points
9,143 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,910 points
7,221 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 3, 2020 in Selenium by Sri
• 3,190 points
7,874 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 23, 2019 in Selenium by Abha
• 28,140 points
5,294 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP