简体   繁体   English

使用 Selenium web Chrome 浏览器驱动程序执行自动化测试时如何绕过 NTLM 身份验证弹出窗口?

[英]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@URLhttps://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.

相关问题 如何在 Z23EEEB4347BDD755BFC6B7EE9A 中使用 selenium firefox 和 chrome 驱动程序翻译 web 页面? - How to translate a web page using selenium firefox and chrome driver in python? Selenium Chromedriver - 点击取消 Chrome 身份验证弹出 - Selenium Chromedriver - Click Cancel Chrome Authentication Pop Up 使用 selenium Chrome 驱动程序清除 Chrome 浏览器中的缓存 - Clear caches in Chrome browser using selenium Chrome driver 在使用Chrome时执行搜索操作,但在Firefox(硒)中不执行 - Performing search opertaion while using chrome but not in firefox(Selenium) Selenium (Python) - 使用 Chrome 网络驱动程序等待下载过程完成 - Selenium (Python) - waiting for a download process to complete using Chrome web driver Selenium 使用 Chrome 浏览器 - HTTP 基本身份验证期间超时 [Python] - Selenium using Chrome browser - Timeout during HTTP basic authentication [Python] Python Selenium Chrome 禁用弹出窗口拦截器 - Python Selenium Chrome Disable Pop Up Blocker 在Selenium中未检测到Chrome警报弹出 - Chrome alert pop up not detected in Selenium 无法从网络浏览器警报弹出窗口中获取带有 Selenium 的文本 - Can not get text with Selenium from web-browser alert pop-up 如何使用 python-selenium 在弹出窗口 window 中单击按钮 - How to click button in pop up window using python-selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM