How to control Login Popup using C# and Selenium?

0

I'm trying to make an automatic web program using C#, Selenium, Internet Explorer 11, Visual studio 2019 and Window 10. But I encounter the following problem.

  1. When I try to access a web page and automatic login (It worked well when I use Python but C#)

    _driver.Navigate().GoToUrl("https://" + ID + ":" + PW + "@www.myWebPage.com/Index.action");

Then an exception occurred.

OpenQA.Selenium.WebDriverException: 'Failed to navigate to https://ID:PW@www.myWebPage.com/Index.action. This usually means that a call to the COM method IWebBrowser2::Navigate2() failed. The error returned is: Received error: 0x800c000e

Then I did some Googling and found another manner.

    _driver.Navigate().GoToUrl("https://www.myWebPage.com/Index.action");
var alert = _driver.SwitchTo().Alert();
alert.SetAuthenticationCredentials(sID, sPW);
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);

And then the web page was just stuck in Login popup.

Could you tell me what's wrong and how to control login popup? Thank you.

c#
selenium
authentication
internet-explorer
visual-studio-2019

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0