Search code examples
c#seleniumauthenticationautomationui-automation

Windows Authentication Pop up Issue in Selinum Automation


I am trying to write UI Automation for a Portal but while Authentication Chrome after entering User name a Pop up comes which can not be handled by selenium c#

I have tried using https://username:password{siteurl}.com

But it didn't work. Also Auto IT nuget is not working. Any suggestions will be really helpful

PFB the screenshot for the same.

Issu


Solution

  • You can't try using a "robot" keyboard which just types in the keyboard. There is no need for the element to be inside the HTML page, as long as you know the prompt is focused:

    Install the NuGet InputSimulator:

    InputSimulator sim = new InputSimulator();  
    sim.Keyboard.TextEntry("User123"); 
    sim.Keyboard.KeyPress(VirtualKeyCode.TAB); 
    sim.Keyboard.TextEntry("Password123"); 
    sim.Keyboard.KeyPress(VirtualKeyCode.RETURN);
    

    This way you just "hit" the keyboard. You code works regardless of the webpage.