0

I wanted to pass credentials to IE through selenium code, for this I have used AutoIt. There is a method in Java to run the AutoIt script, but I cannot find equivalent method in C#.

Runtime.getRuntime().exec(“D:\\SoftwareTestingMaterial\\AutoIt\\SendCredentials.exe”);

I need equivalent method in C#.

3
  • you dont run an auto script, you run an executable (maybe an autoit compiled but its executable). You want to run an executable in C#? Commented Apr 23, 2020 at 15:53
  • AutoItX3 sendcredentials = new AutoItX3(); sendcredentials.WinWaitActive("Windows Security"); sendcredentials.Send("my username"); Thread.Sleep(TimeSpan.FromSeconds(2)); sendcredentials.Send("{TAB}"); sendcredentials.Send("mypassword"); Thread.Sleep(TimeSpan.FromSeconds(2)); sendcredentials.Send("{ENTER}"); I have used this in my code still no luck Commented Apr 23, 2020 at 15:57
  • 2
    what is no luck? the Sleep is the cause? or other? Commented Apr 23, 2020 at 16:13

1 Answer 1

2

Karanam - For AutoIT in C# load NuGet package AutoIT. Then you can do something like this without using an exe file.

        public static void LogIn()
    {

        AutoItX.AutoItSetOption("WinTitleMatchMode", 2);
        AutoItX.WinActivate("Google Chrome");
        AutoItX.WinWaitActive("Google Chrome", "", 15);

        for (int i = 0; i < 10; i++)
        {
            bool ele1 = AutoItX.WinExists("[CLASS:Chrome_WidgetWin_1]") == 1;
            if (ele1)
            {
                AutoItX.WinActivate("[CLASS:Chrome_WidgetWin_1]");
                AutoItX.Send("user");
                Thread.Sleep(250);
                AutoItX.Send("{TAB}");
                Thread.Sleep(250);
                AutoItX.Send("pass");
                Thread.Sleep(250);
                AutoItX.Send("{ENTER}");
                Thread.Sleep(1000);
            }


        }

    }

If you want to run an exe file in C# you need:

Process.Start("C:\MyPath\To\File");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.