Reputation: 11
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#.
Upvotes: 0
Views: 2547
Reputation: 1551
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");
Upvotes: 2