[英]How to By Pass NTLM authentication pop up while performing automation testing using Selenium web driver for Chrome browser?
I used the following python code to bypass the NTLM popup.我使用以下 python 代码绕过 NTLM 弹出窗口。
chromedriver = webdriver.Chrome(executable_path=chromedriver_path, chrome_options=options)
chromedriver.get("https://username:password@url.com")
The popup couldn't bypass and still exists and test breaks.弹出窗口无法绕过并且仍然存在并且测试中断。
As @BhuvaneshMani has mentioned in the comment's on this answer ... 正如@BhuvaneshMani在评论中提到的这个答案 ......
You need to observe how the NTLM is getting authenticated. 您需要观察NTLM如何通过身份验证。 (use the devTools in chrome under Network)
(在网络下使用chrome中的devTools)
After you find the authentication call use that URL! 找到身份验证调用后使用该URL!
As @BhuvaneshMani's example: 作为@ BhuvaneshMani的例子:
For eg, app url may be app.url however after hitting the url, it redirects to auth.server.url. So if you append username and password into app.url it wont work. It should be appended to auth.server.url.
So your code should look something like this: 所以你的代码应该是这样的:
driver = webdriver.Chrome(executable_path=chromedriver_path, chrome_options=options)
driver.get("https://username:password@auth.server.com")
Or (I found that most authentication calls are to the same URL just to the server port: port:8080/auth/login
) 或者(我发现大多数身份验证调用只是到服务器端口的相同URL:
port:8080/auth/login
)
driver.get("https://username:password@url.com:8080/auth/login")
Hope this helps you! 希望这对你有所帮助!
You might be facing issue for domain login as browser converts domain separator \\
to /
and credentials become invalid. 你可能会面临的问题域登录的浏览器域分隔符转换
\\
到/
和证书无效。 Use encoded separator %5C
and it will work. 使用编码的分隔符
%5C
,它将工作。
Browser will convert https://domain\\username:password@URL
to https://domain/username:password@URL
. 浏览器会将
https://domain\\username:password@URL
为https://domain/username:password@URL
。
User encoded separator for request. 用户编码的请求分隔符。
https://domain\\username:password@URL
=> https://domain%5Cusername:password@URL
https://domain\\username:password@URL
=> https://domain%5Cusername:password@URL
You could also enable Chrome to authenticate with NTLM as the current user with similar .reg
file to the following:您还可以让 Chrome 以当前用户身份使用 NTLM 进行身份验证,并使用类似于以下内容的
.reg
文件:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome]
"AuthNegotiateDelegateWhitelist"="*.companydomain.org,*.companydomain.coop"
"AuthSchemes"="basic,digest,ntlm,negotiate"
"AuthServerWhitelist"="*.companydomain.org,*.companydomain.coop"
https://dev.to/seankilleen/quick-tip-ntlm-windows-pass-through-authentication-with-selenium-and-chromedriver-34m6 https://dev.to/seankilleen/quick-tip-ntlm-windows-pass-through-authentication-with-selenium-and-chromedriver-34m6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.