我正在使用Selenium WebDriver进行自动化,并希望处理浏览器身份验证窗口。我知道Selenium本身不支持这一点,但我可以使用AutoIt。我们必须与客户端共享我们的代码,那么AutoIt代码可以从Eclipse中管理吗?代码如下:
WinWaitActive("Authentication Required", "", "120")
If WinExists("Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf从Eclipse运行AutoIt.exe的代码:
Runtime.getRuntime().exec("C:\\NewAutoIT.exe");有没有办法在Eclipse中管理AutoIt代码?
发布于 2014-05-12 02:31:17
你应该使用库AutoItX4Java,它允许在Java中执行AutoIt命令。
你需要安装AutoIt并使用Java COM Bridge库,然后你就可以直接用Java语言编程了。不久前我在我的网站上发表了一篇文章,但这里有一个简单的例子:
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
复制相似问题