Last week, I worked on Selenium; not for testing purposes, but for automating a workflow in my project. To automate that workflow, I had to cross a big hurdle - a Windows Authentication popup in between the workflow. I tried everything like appending URL with credentials but nothing worked. At the end, I got to know about autoitx.dotnet NuGet application.
Problem statement
How to authenticate Windows user login when working on Selenium.
Solution
- I am assuming you already have a running project with Selenium.
- Now, go to the NuGet gallery and search for “Autoit” NuGet.
- Install the above NuGet package.
- Now, add the below code where you want to authenticate Windows User Login.
- IWebDriver driver = new InternetExplorerDriver();
- driver.Navigate().GoToUrl("http://localhost/Home/StephenSecrets");
-
- AutoItX.WinWaitActive("Windows Security");
- AutoItX.ControlSetText("Windows Security", "", "Edit1", "TestUser");
- AutoItX.ControlSetText("Windows Security", "", "Edit2", "Password_test");
- AutoItX.Send("{ENTER}");
- It’s done.
- You can find this sample project on my GitHub repo.