我的应用程序有一个功能,如注册客户,注册卡(为添加的客户),注册优惠。
所有的事情,无论是我可以登记一个客户一个或卡一个等从前端浏览器。
我们已经通过Selenium自动化了这些东西。现在创建了一个实用程序(vbscript) (UI模式和非UI模式)。您可以添加n个客户/卡/优惠,方法是在实用程序中提供txt文件(txt文件应包含所有客户详细信息)作为输入文件,或通过命令提示符(非UI)使用实用程序名称和文件名运行实用程序。
现在我需要写一段代码来打开实用程序文件并导入txt文件,以及在cmd提示符中输入命令并运行此命令,然后转到应用程序(在浏览器中)验证所有内容是否都已添加?
我知道selenium在帮助你实现浏览器端自动化方面有局限性,但我听说有AutoIt可以做到这一点。如果在java中有一种方法也不错..
有谁知道我们能做到这一点吗?
发布于 2015-04-02 14:43:46
Selenium可以用于自动化web浏览器的部分,而AutoIT则应该用于自动化Windows应用程序。
此链接提供了有关如何与Selenium一起使用AutoIT的良好信息:http://www.toolsqa.com/selenium-webdriver/autoit-selenium-webdriver/
下面是你必须做的事情:
下载/安装AutoIT
您将能够使用AutoIT SciTe编辑器创建.au3脚本编译.au3脚本将为您提供一个.exe文件,然后您可以使用从Selenium脚本调用.exe文件
Runtime.getRuntime().exec("D:\AutoIt\AutoItTest.exe");可以使用AutoIT窗口信息(x86)或(x64)获取窗口的属性。例如,窗口的标题/状态栏。
AutoIT还具有Au3记录器,以便您可以记录与远程桌面相关的操作。
以下是自动执行Http身份验证的示例脚本:
WinWaitActive("Web page title","","10")
If WinExists("Web page title") Then
Send("userid{TAB}")
Send("password{Enter}")
EndIf下面的脚本获取记事本状态栏中显示的文本:
WinWaitActive("Untitled - Notepad", "", 30)
Local $hWnd = WinGetHandle("Untitled - Notepad")
Local $sText = StatusbarGetText("Untitled - Notepad","",2)
ConsoleWrite($sText) 我希望这些信息能有所帮助!
由于您正在寻找解决方案:尝试AutoITx4Java - https://code.google.com/p/autoitx4java/
示例代码
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));发布于 2015-04-02 14:36:42
我对你的问题不是很清楚。但据我所知,您可以从cmd提示符运行您的实用程序,也可以从您的java代码执行它。请检查此answer
正如您所指出的,您可以使用autoit或sikuli来自动化ui部件。
https://stackoverflow.com/questions/29406341
复制相似问题