Execute AutoIt code from Eclipse

有些话、适合烂在心里 提交于 2021-02-07 04:06:37

问题


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:


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));


来源:https://stackoverflow.com/questions/23590413/execute-autoit-code-from-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!