首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >执行Eclipse中的AutoIt代码

执行Eclipse中的AutoIt代码
EN

Stack Overflow用户
提问于 2014-05-11 16:11:46
回答 1查看 17.6K关注 0票数 3

我正在使用Selenium WebDriver进行自动化,并希望处理浏览器身份验证窗口。我知道Selenium本身不支持这一点,但我可以使用AutoIt。我们必须与客户端共享我们的代码,那么AutoIt代码可以从Eclipse中管理吗?代码如下:

代码语言:javascript
复制
WinWaitActive("Authentication Required", "", "120")
If WinExists("Authentication Required") Then
   Send("username{TAB}")
   Send("password{Enter}")
EndIf

从Eclipse运行AutoIt.exe的代码:

代码语言:javascript
复制
Runtime.getRuntime().exec("C:\\NewAutoIT.exe");

有没有办法在Eclipse中管理AutoIt代码?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-12 02:31:17

你应该使用库AutoItX4Java,它允许在Java中执行AutoIt命令。

你需要安装AutoIt并使用Java COM Bridge库,然后你就可以直接用Java语言编程了。不久前我在我的网站上发表了一篇文章,但这里有一个简单的例子:

代码语言:javascript
复制
    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));
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23590413

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档