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

查看:66
本文介绍了从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天全站免登陆