【问题标题】:How can I detect Windows Authentication Prompts with Selenium web driver?如何使用 Selenium Web 驱动程序检测 Windows 身份验证提示?
【发布时间】:2016-09-14 06:11:39
【问题描述】:

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

在使用 IE 时,我们会在某些页面上收到重新验证的提示。 (我们怀疑这与我们的 F5 负载均衡器有关)

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

【问题讨论】:

    标签: c# selenium-webdriver windows-authentication f5


    【解决方案1】:

    您必须等待并收到警报。

    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");
    

    【讨论】:

    • 到目前为止效果很好,只是添加了 simpleAlert.Accept();当我需要它登录时。
    • 这行不通。 Navigate().GoToUrl() 块,等到输入凭据,所以下面的代码永远不会执行。你会得到一个超时异常。
    • 我也得到了超时。有解决办法吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-11
    • 2017-10-17
    • 1970-01-01
    • 2015-02-05
    相关资源
    最近更新 更多