从 Eclipse 执行 AutoIt 代码 [英] Execute AutoIt code from Eclipse

查看:35
本文介绍了从 Eclipse 执行 AutoIt 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

从 Eclipse 运行 AutoIt.exe 的代码:

Code to run the AutoIt.exe from Eclipse:

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

有没有办法从 Eclipse 管理 AutoIt 代码?

Is there any way to manage AutoIt code from Eclipse?

推荐答案

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

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

您需要安装AutoIt并使用Java COM Bridge库,然后您可以直接在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));

这篇关于从 Eclipse 执行 AutoIt 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆