DEV Community

Cover image for πŸ›‘πŸ›‘  How to Handle Proxy in Selenium(with Demo)? πŸ›‘πŸ›‘
Pramod Dutta
Pramod Dutta

Posted on • Edited on

πŸ›‘πŸ›‘ How to Handle Proxy in Selenium(with Demo)? πŸ›‘πŸ›‘

βœ… Join us - https://sendfox.com/thetestingacademy

In this video, We are going to learn How to Handle Proxy in Selenium(with Demo) | Handle Proxy Authentication.

πŸš€ What is a Proxy Server?

A proxy server acts as a gateway between you and the internet. It's an intermediary server separating end users from the websites they browse.

Proxy servers act as a firewall and web filter, provide shared network connections, and cache data to speed up common requests

 Proxy in Selenium

πŸš€ Code to Handle it

Download Code : - https://scrolltest.com/automation/proxy

πŸš€ How to Handle Proxy Authentication?

You can do via MultiPass for HTTP basic authentication

Download the extension from
https://chrome.google.com/webstore/detail/multipass-for-http-basic/enhldmjbphoeibbpdhmjkchohnidgnah

Download the extension as crx. You can get it as crx from chrome-extension-downloader

After that the config is simple.


  static  void initDriver() {
        ChromeOptions cOptions = new ChromeOptions();
        cOptions.addExtensions(new File("MultiPass-for-HTTP-basic-authentication_v.crx"));
        driver = new ChromeDriver(cOptions);
        configureAuth(
                "https://the-internet.herokuapp.com/basic_auth",
                "admin",
                "admin");
    }

 static void configureAuthWithExtension(String url, String username, String password) {
        driver.get("chrome-extension://enhldmjbphoeibbpdhmjkchohnidgnah/options.html");
        driver.findElement(By.id("url")).sendKeys(url);
        driver.findElement(By.id("username")).sendKeys(username);
        driver.findElement(By.id("password")).sendKeys(password);
        driver.findElement(By.className("credential-form-submit")).click();
    }

πŸš€ Charles DownLoad :

https://www.charlesproxy.com/

--
Be sure to subscribe for more videos like this!

 TheTestingAcademy

Top comments (0)