Search code examples
c#seleniumfirefoxwindows-authentication

I am not able to open my application using FireFox C# selenium webdriver


I want to test my unit cases using firefox. I am using C# selenium webdriver. My application uses windows authentication. The code is

FirefoxOptions d= new FirefoxOptions();

In URL i am passing username and password


Solution

  • Amna - I am looking for a better way to handle Windows Authentication but here is something that will work.

    Add NuGet package AutoIT

    Then add this to your login:

    bool ele1 = AutoItX.WinExists("[CLASS:MozillaDialogClass]")== 1;
    
    if (ele1)
    {
    AutoItX.WinActivate("[CLASS:MozillaDialogClass]"); 
    AutoItX.Send("Username");
    AutoItX.Send("{TAB}");
    AutoItX.Send("Password");
    AutoItX.Send("{ENTER}");
    }
    

    Alert Login was Deprecated as was user/pass in the url string. AutoIT is the only thing that has worked but it is not thread safe so you have to run single thread.