简体   繁体   English

使用Selenium Java传递用户名和密码以及用于登录的URL时出错

[英]Error in passing username and password along with the url for login using Selenium Java

Related to this question: How to handle login pop up window using Selenium WebDriver? 与此问题相关: 如何使用Selenium WebDriver处理登录弹出窗口?

url I am using: 我正在使用的网址:

https://username:password@url.com

When I try to enter the url containing username and password in IE 11, it gives an error. 当我尝试在IE 11中输入包含用户名和密码的URL时,出现错误。

Windows cannot find '...url...'. Check the spelling and try again.

I tried the other methods and none of them is working, but that is because the login pop up is a Windows Security window and not normal js alert. 我尝试了其他方法,但没有一个起作用,但这是因为登录弹出窗口是Windows安全性窗口,而不是正常的js警报。 Here I asked that question: https://sqa.stackexchange.com/questions/35002/how-to-handle-password-alert-pop-up-windows-security-on-ie 在这里我问了这个问题: https : //sqa.stackexchange.com/questions/35002/how-to-handle-password-alert-pop-up-windows-security-on-ie

This method is giving a different error and I am curious as to why this is the case. 这种方法给出了一个不同的错误,我很好奇为什么会这样。 Some permission missing that allows the url to contain credentials? 缺少一些允许URL包含凭据的权限?

Found an answer: https://stackoverflow.com/a/30372668 找到了答案: https : //stackoverflow.com/a/30372668

I've just encountered that problem myself. 我自己遇到了这个问题。 For me, the problem was that my application uses HTTP Basic Authentication, and that I was attempting to set the username/password combination via the page URL, like this: http://username:password@host/path 对我来说,问题在于我的应用程序使用HTTP基本身份验证,并且我试图通过页面URL设置用户名/密码组合,例如: http:// username:password @ host / path

Problem is by default IE doesn't allow you to set the username and password this way (it's a security feature), and that causes the error above. 问题是默认情况下IE不允许您以这种方式设置用户名和密码(这是一项安全功能),这会导致上述错误。

To fix this, I had to add a registry value in regedit. 要解决此问题,我必须在regedit中添加一个注册表值。 In the key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE add a new DWORD value with the name iexplore.exe and the value 0, as described in this other answer https://stackoverflow.com/a/23519791/80779 在密钥中:HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ Internet Explorer \\ MAIN \\ FeatureControl \\ FEATURE_HTTP_USERNAME_PASSWORD_DISABLE添加一个新的DWORD值,名称为iexplore.exe,值为0,如其他答案所述:https://stackoverflow.com/a/八万〇七百七十九分之二千三百五十一万九千七百九十一

And this: Basic authentication with Selenium in Internet Explorer 10 这是: Internet Explorer 10中使用Selenium进行基本身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM