如何使用Java使用selenium web驱动程序进行基本的http身份验证

时间:2015-09-22 05:36:07

标签: java http selenium-webdriver

我尝试了以下方法来进行基本的http身份验证,但它对我没用。

 FirefoxProfile profile = new FirefoxProfile();
 profile.setPreference("network.http.phishy-userpass-length", 255);
 driver = new FirefoxDriver(profile);

在此之后,我通过以下方法传递了用户名和密码。

 driver.get("https://username:password@<<URL>>");

如果密码中有任何特殊字符,请如何在URL中传递它。

是否有任何通用解决方案可以在所有浏览器上解决此问题。

1 个答案:

答案 0 :(得分:0)

不,据我所知,我不认为所有浏览器都有通用的方法。 现在针对您的问题,请尝试下面提到。

由于您的HTTP代理,请验证您是否已启用“browser.safebrowsing.malware.enabled”选项为True。

要执行此操作,请在Firefox中键入about:config。 搜索browser.safebrowsing.malware.enabled,双击它。

看看是否有帮助。