Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute AutoIt code from Eclipse

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?

like image 559
Naseem Avatar asked Apr 01 '26 05:04

Naseem


1 Answers

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));
like image 57
ron190 Avatar answered Apr 02 '26 19:04

ron190



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!