IE Windows Security dialog appears to block Selenium navigation

北城以北 提交于 2019-12-11 15:48:34

问题


I am using Selenium in C# on Windows 10. The site under test should challenge with a Windows Security login box in IE, which it does. But the login box appears to block the call.

var home = "https://site.under.test.com/"; 
driver = new InternetExplorerDriver(AppDomain.CurrentDomain.BaseDirectory);

driver.Url = home;
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl(home + "secure/");

//code to handle login box goes here, never gets executed unless the dialog box 
//is manually addressed or something times out in GoToURL(), 
//and then the dialog box doesn't work.

The login box appears: Click here for screenie of the login box

But the execution is stalled on the GoToUrl() call: Click here for screenie of execution

Doesn't matter what code I place after this to handle the popup, execution is blocked until something times out inside GoToUrl().

Is this expected behavior? How does one get around it?

Clarification: The problem is not how to enter data into the popup. It is about the code execution not advancing to the point where I can enter data into the popup without intervention or timeout.

This works on Win8.1, but not on Win10


回答1:


The Webdriver no longer officially supports Basic Authentication. It has been removed from the Java code and the .Net version works accidentally. From my experience you can expect it to work (for now) on Win7-8.1, but not on Win10

This from Selenium support: The support of authentication dialogs was removed from the java bindings with this commit.

I am surprised, they are still present in the c# binding, because there is no support for basic authentication in the webdriver specification.




回答2:


Not sure if you found the answer yet but here is what I found so far.

.GoToUrl waits for the page to load and since the page has not loaded yet, it waits and waits and throws exception.

You can enter the url usign Javascript. Below for is .Net code for it

string script = "window.location = \'" + url + "\'";
((IJavaScriptExecutor)driver).ExecuteScript(script);

You have to manage your own wait after using the above code.

And Selenium still doesnt work with the Windows Security dialog that you see after this (Or, I havent found any info anywhere that shows how to make Selenium work with this dialog)

The best solution I have found so far is to use AutoIT, and use TAB commands within AutoIT to enter username, move to password adn enter password and then do tab tab until you get to submit button and then click on this location. Please comment here if you have found any better solution than this until now



来源:https://stackoverflow.com/questions/50470369/ie-windows-security-dialog-appears-to-block-selenium-navigation

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