如何使用Selenium Web驱动程序检测Windows身份验证提示? [英] How can I detect Windows Authentication Prompts with Selenium web driver?

查看:100
本文介绍了如何使用Selenium Web驱动程序检测Windows身份验证提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#脚本来测试某些SharePoint网站.

I have a C# script to test some SharePoint sites.

使用IE时,我们会在某些页面上提示您重新进行身份验证. (我们怀疑这与我们的F5负载平衡器有关)

We are getting prompts to reauthenticate on some pages when using IE. (We suspect it is something to do with our F5 load balancer)

我希望能够创建一个可以访问页面的脚本,然后让我知道该页面是否具有Windows身份验证提示? 目前,我不需要通过提示符登录即可.

I want to be able to create a script that can visit pages and then let me know if the page had a Windows Authentication Prompt? At the moment I don't need to login through the prompt just detect it.

推荐答案

您必须等待并捕获警报.

You have to wait and catch the alert.

driver.Navigate().GoToUrl("url_where_your_WAP_is");
WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 1, 0));

IAlert simpleAlert = wait.Until(ExpectedConditions.AlertIsPresent());
simpleAlert.SetAuthenticationCredentials("user", "password");

这篇关于如何使用Selenium Web驱动程序检测Windows身份验证提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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