获取硒通过的.htaccess弹出登录 [英] Getting Selenium to login via .htaccess popup
问题描述
我使用webdriver的(Selenium2)与Java在Linux上。我使用webdriver的自动填表并提交。我现在面临的问题与htaccess的网站即我无法通过webdriver的访问htaccess的网站。
I am using WebDriver (Selenium2) with Java on linux. I am using WebDriver to auto fill form and submit it. I am facing problem with htaccess sites i.e., I am not able to access htaccess site through WebDriver.
谁能帮我在这方面?
在此先感谢, 苏尼尔
推荐答案
从<一个href="http://wiki.openqa.org/display/SEL/Selenium+Core+FAQ#SeleniumCoreFAQ-HowdoIuseSeleniumtologintositesthatrequireHTTPbasicauthentication%28wherethebrowsermakesamodaldialogaskingforcredentials%29%3F">Selenium常见问题解答(这是下降的时刻):
From Selenium FAQ (which is down at the moment):
我如何使用Selenium登录到需要HTTP基本身份验证(如浏览器发出一个模式对话框,要求您提供凭据)的网站?
How do I use Selenium to login to sites that require HTTP basic authentication (where the browser makes a modal dialog asking for credentials)?
使用一个用户名和密码的网址,如RFC 1738中所述:
测试类型
打开<一href="http://myusername:myuserpassword@myexample.com/blah/blah/blah">http://myusername:myuserpassword@myexample.com/blah/blah/blah
Use a username and password in the URL, as described in RFC 1738:
Test Type
open http://myusername:myuserpassword@myexample.com/blah/blah/blah
请注意,在Internet Explorer中这是行不通的,因为微软在IE浏览器中禁用的URL的用户名/密码。但是,可以通过修改注册表,作为链接的知识库文章中所述添加的功能。最在HKEY_CURRENT_USER \ SOFTWARE \微软\的Internet Explorer \ MAIN \ FeatureControl \ FEATURE_HTTP_USERNAME_PASSWORD_DISABLE设置IEXPLORE.EXEDWORD 0。
Note that on Internet Explorer this won't work, since Microsoft has disabled usernames/passwords in URLs in IE. However, you can add that functionality back in by modifying your registry, as described in the linked KB article. Set an "iexplore.exe" DWORD to 0 in HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE.
如果你不想自己修改注册表,你总是可以只使用硒的远程控制,自动设置,随着0.9.2版本的注册表项,为你。
If you don't want to modify the registry yourself, you can always just use Selenium Remote Control, which automatically sets that that registry key for you as of version 0.9.2.
这篇关于获取硒通过的.htaccess弹出登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!