[英]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? 我正在使用Mozilla firefox,当使用给定的URL打开浏览器时,它具有要求用户名和密码的代理身份验证。是否有解决方案,可以删除该用户名和密码?
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 :) 这种解决方案大多数时候是针对Java的C#,您需要小写字母:)
var alert = driver.SwitchTo().Alert();
alert.SetAuthenticationCredentials("username", "password");
alert.Accept();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.