如何绕过selenium中的身份验证
我正在尝试自动化一个安全应用程序(使用 useragent - iphone),当我打开网站时,该应用程序要求进行身份验证。我尝试在 URL 本身中提供凭据来绕过身份验证,但它会弹出一个对话框进行确认,我无法通过代码处理它。
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override",
"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1"
+ "(KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3)");
WebDriver driver = new FirefoxDriver(profile);
String site = "http://akamai:[email protected]";
driver.get(site);
对此的任何帮助都将受到高度赞赏。
谢谢, 巴瓦那
I'm trying to automate a secure application(with useragent - iphone) which asks for authentication when i open the site. I tried giving the credentials in the URL itself to bypass the authentication but it pops up a dialogbox for confirmation which i'm unable to handle it through code.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("general.useragent.override",
"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1"
+ "(KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3)");
WebDriver driver = new FirefoxDriver(profile);
String site = "http://akamai:[email protected]";
driver.get(site);
Any help on this is highly appreciated.
Thanks,
Bhavana
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Mozilla 阻止钓鱼尝试。您检查过 Network.http.phishy-userpass-length 吗?
顺便说一句,根据 Selenium 的问题 34#8,这应该有效:
注意:这个问题几乎与 BASIC Authentication in Selenium 2 相同- 设置 FirefoxDriver、ChromeDriver 和 IEdriver。
Mozilla blocks fishing attempts. Did you check Network.http.phishy-userpass-length?
By the way, according to Selenium's issue 34#8, this should work:
Note: this question is almost the same as BASIC Authentication in Selenium 2 - set up for FirefoxDriver, ChromeDriver and IEdriver.
您可以使用 Selenium 的新 WebDriver 将信息输入到该类型的对话框中。然而我还没有做到。
You can use Selenium's new WebDriver to enter information into a dialog box of that type. However I haven't done it.