简体   繁体   中英

How to handle proxy authentication in mozilla firefox using selenium?

I am using Mozilla firefox and when the browser is open with given URL,it has a proxy authentication that asking username and password..Is there any solution to remove that?

here's my code:

public class SimpleSelenium {

    WebDriver driver = null;

    public static void main(String args[]) {
        SimpleSelenium ss = new SimpleSelenium();
        ss.openBrowser();
        ss.getPage();
        ss.quitPage();
    }

    private void openBrowser() {
        System.setProperty("webdriver.gecko.driver", "C:/geckodriver.exe");
        DesiredCapabilities capabilities = DesiredCapabilities.firefox();
        capabilities.setCapability("marionette", true);
        driver = new FirefoxDriver(capabilities);
    }

    private void quitPage() {
        driver.quit();
    }

    private void getPage() {
        driver.get("http://www.google.com");        
    }
}

If it is browser authentication you can use;

this solution is for c# for java most of the time you need to lower case the letter :)

var alert = driver.SwitchTo().Alert();
alert.SetAuthenticationCredentials("username", "password");
alert.Accept();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM