如何在Selenium WebDriver中对FirefoxDriver,ChromeDriver和IEdriver执行基本身份验证? [英] How to perform Basic Authentication for FirefoxDriver, ChromeDriver and IEdriver in Selenium WebDriver?
问题描述
我使用的是Selenium-Firefox驱动程序 和 Selenium-Chrome驱动程序版本2.0a5( Web Driver API 我试图测试一个具有BASIC身份验证的Web应用程序(当我点击任何页面时弹出一个弹出窗口来验证用户,弹出窗口不是HTML的一部分)。
I am using the Selenium-Firefox-driver and Selenium-Chrome-Driver version 2.0a5 (Web Driver API), and I am trying to test a web app that has BASIC authentication (there is a popup that come up to authenticate the user when I hit whatever page, the popup is not part of the HTML).
现在,我需要一个在Firefox,Chrome和IE中验证用户的策略(我马上导入IE驱动程序)。
Now, I need to a strategy to authenticate the user in Firefox, Chrome and IE (I'm going to import the IE Driver soon).
我在几篇文章中阅读,我可以设置一个Firefox配置文件,例如:
I was reading in few articles that I can set a Firefox profile for instance..something like:
FirefoxProfile ffProfile = new FirefoxProfile();
ffProfile.setPreference("network.http.phishy-userpass-length", 255);
WebDriver driver = new FirefoxDriver(ffProfile);
driver.get("http://username:password@hostname");
但它似乎并不适用于我。
but it doesn't seem to work for me. Does anyone have a working solution for those browsers?
推荐答案
True,BASIC HTTP认证目前不支持,但我现在正在工作用于FF和Chrome。
True, BASIC HTTP authentication is not currently supported but I got it working now for FF and for Chrome.
我在问题中写的代码适用于那些驱动程序。我只是尝试使用FF3.6作为Firefox默认浏览器(安装在Firefox文件夹)而不是FF4(不支持)。对于IE,我可能会尝试通过Windows注册表禁用身份验证。
The code I wrote in the questions works for those drivers. I just tried using FF3.6 as Firefox default browser (installed in Firefox folder) instead of FF4 (not supported yet). For IE, i may try to disable the authentication through Windows Registry.
此页面 http://code.google.com/p/selenium/issues/detail?id=34 可能会有帮助。
这篇关于如何在Selenium WebDriver中对FirefoxDriver,ChromeDriver和IEdriver执行基本身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!