处理Windows身份验证与硒的webdriver [英] Handling Windows authentication with Selenium Webdriver

查看:235
本文介绍了处理Windows身份验证与硒的webdriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中硒的webdriver基础的测试必须windows身份验证登录。

Selenium Webdriver based test in C# must login with windows authentication.

我已经尝试了几个方法:

I have tried a couple of approaches:

  _Driver.SwitchTo().Alert();
  _Driver.FindElement(By.Id("UserName")).SendKeys("LynnTest");
  _Driver.FindElement(By.Id("Password")).SendKeys("Welcome1!");
  _Driver.SwitchTo().Alert().Accept();
  _Driver.SwitchTo().DefaultContent();

  IAlert alert = _Driver.SwitchTo().Alert();
  alert.SendKeys("LynnTest\\t");
  alert.SendKeys("Welcome1!");
  _Driver.SwitchTo().Alert().Accept();
  _Driver.SwitchTo().DefaultContent();



无论一个是成功的。我没有得到我的本地系统上的Windows身份验证对话框让我无法查看源,以确定如何找到与硒的方法通过用户名和密码。

Neither one is successful. I don't get the windows authentication dialog on my local system so I can't view the source to determine how to locate the username and password with the Selenium By method.

我相信是由浏览器提供的windows身份验证对话框,但是我还没有找到对话的任何来源。

I believe the windows authentication dialog is provided by the browser, but I haven't found any source for the dialog.

使用硒(不AutoIt的或其他类似的工具)我该如何通过用户名和密码进入windows身份验证对话框?该解决方案必须基于硒代码,而不是插件,我要浏览器无法访问的是在云

Using Selenium (not AutoIt or other similar tools) how do I pass a username and password into the windows authentication dialog? The solution must be based on Selenium code, not add-ins, I have no access to the browsers as the are in the cloud.

请注意:通过用户名和密码在URL不起作用,因为我理解,因为不是由HTML网页上生成的对话框。

Note: passing the username and password in the URL does not work, as I understand because the dialog is not generated by html on the page.

推荐答案

在年底我用了一个解决办法,先导航到认证页面,认证,然后重定向到页面进行测试作为身份验证的用户。这种方法使用的页面可脚本内部认证页面。

In the end I used a workaround, navigating first to the authentication page, authenticating and then redirecting to the page to be tested as an authenticated user. This approach uses pages internal authentication page which can be scripted to.

这篇关于处理Windows身份验证与硒的webdriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆