3

I am doing automation using Selenium WebDriver and want to handle a browser authentication window. I know Selenium does not support this on its own but I am able to using AutoIt. We have to share our code with the client, so can AutoIt code be managed from Eclipse? This is the code:

WinWaitActive("Authentication Required", "", "120")
If WinExists("Authentication Required") Then
   Send("username{TAB}")
   Send("password{Enter}")
EndIf

Code to run the AutoIt.exe from Eclipse:

Runtime.getRuntime().exec("C:\\NewAutoIT.exe");

Is there any way to manage AutoIt code from Eclipse?

1 Answer 1

10

You should use library AutoItX4Java, it allows to execute AutoIt commands in Java.

You need to install AutoIt and use the library Java COM Bridge, then you can program directly in Java. I made a post on my site a while ago, but here is a simple example:

    File file = new File("lib", "jacob-1.15-M4-x64.dll"); //path to the jacob dll
    System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath());

    AutoItX x = new AutoItX();
    String notepad = "Untitled - Notepad";
    String testString = "this is a test.";
    x.run("notepad.exe");
    x.winActivate(notepad);
    x.winWaitActive(notepad);
    x.send(testString);
    Assert.assertTrue(x.winExists(notepad, testString));
    x.winClose(notepad, testString);
    x.winWaitActive("Notepad");
    x.send("{ALT}n");
    Assert.assertFalse(x.winExists(notepad, testString));
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Ron.... I was able to implement AutoiTX with Jacob successfully in my project. Just want to add 1 point here is that Auto IT also need to be installed in the machine to run this.
That is a good point Naseem. If this software is sold you must ensure that dependency is covered within your installer. It is easily missed.
Here is the good explanation and details around this. joecolantonio.com/2014/07/02/…

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.