Nas*_*eem 3 java eclipse selenium autoit selenium-webdriver
我正在使用Selenium WebDriver进行自动化,并希望处理浏览器身份验证窗口.我知道Selenium不支持这个,但我可以使用AutoIt.我们必须与客户共享我们的代码,因此可以从Eclipse管理AutoIt代码吗?这是代码:
WinWaitActive("Authentication Required", "", "120")
If WinExists("Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf
Run Code Online (Sandbox Code Playgroud)
从Eclipse运行AutoIt.exe的代码:
Runtime.getRuntime().exec("C:\\NewAutoIT.exe");
Run Code Online (Sandbox Code Playgroud)
有没有办法从Eclipse管理AutoIt代码?
您应该使用库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));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15444 次 |
| 最近记录: |