How can I detect Windows Authentication Prompts with Selenium web driver?

一世执手 提交于 2019-12-24 15:29:38

问题


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

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

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.


回答1:


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


来源:https://stackoverflow.com/questions/37288057/how-can-i-detect-windows-authentication-prompts-with-selenium-web-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!