razor1509 razor1509 - 1 month ago 8
C# Question

Can't handle chrome/firefox login popup window

I just started working on an automation framework for a

asp.net
app using
selenium webdriver
with
C#
. When I go to the url, a login pop-up is displayed asking for credentials(username, password).

I have been able to handle this on
IE
, using

driver.Navigate().GoToUrl("http://mywebsite.com");
IAlert alert = driver.SwitchTo().Alert();
alert.SetAuthenticationCredentials(@"ad\username", "password");
alert.Accept();


However, this solution doesn't work for
Firefox
or
Chrome
.
I also tried

driver.Navigate().GoToUrl("http://mywebsite.com");
IAlert alert = driver.SwitchTo().Alert();
alert.SendKeys(@"ad\username");
alert.SendKeys(Keys.Tab);
alert.SendKeys("password");
alert.Accept();


and

WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
IAlert alert = wait.Until(ExpectedConditions.AlertIsPresent());


and this doesn't seem to work either.

Is anyone has any idea of how should I approach this, please let me know.

Thanks.

Answer

Solved for Firefox using AutoIT and following this tutorial Handle windows authentication in Selenium Webdriver.