jmeter结合autoit操作windows程序
需求:
模拟操作下图软件的控件,如拨号和挂机。
1. 下载安装好autoit后,打开finder tool,使用查找工具定位到要模拟操作的控件上,如图:
2.在finder tool中的control选项卡,可以看到该控件的信息。其它控件做类似操作
3.打开autoit的script editor,编写模拟操作控件的脚本
Dim $dialogTitle = "MicroSIP" WinActivate($dialogTitle) WinWaitActive($dialogTitle) ;1 ControlFocus("MicroSIP", "","[Class:Button;Instance:7]") Sleep(1000) ControlClick("MicroSIP", "","[Class:Button;Instance:7]") ;0 ControlFocus("MicroSIP", "","[Class:Button;Instance:16]") Sleep(1000) ControlClick("MicroSIP", "","[Class:Button;Instance:16]") ControlFocus("MicroSIP", "","[Class:Button;Instance:16]") Sleep(1000) ControlClick("MicroSIP", "","[Class:Button;Instance:16]") ;8 ControlFocus("MicroSIP", "","[Class:Button;Instance:14]") Sleep(1000) ControlClick("MicroSIP", "","[Class:Button;Instance:14]") ;6 ControlFocus("MicroSIP", "","[Class:Button;Instance:12]") Sleep(1000) ControlClick("MicroSIP", "","[Class:Button;Instance:12]") ;2 ControlFocus("MicroSIP", "","[Class:Button;Instance:8]") Sleep(1000) ControlClick("MicroSIP", "","[Class:Button;Instance:8]") ControlFocus("MicroSIP", "","[Class:Button;Instance:8]") Sleep(1000) ControlClick("MicroSIP", "","[Class:Button;Instance:8]") ControlFocus("MicroSIP", "","[Class:Button;Instance:1]") Sleep(1000) ControlClick("MicroSIP", "","[Class:Button;Instance:1]")
4.保存为au3文件,点击scrit的tools->go。测试运行,通过后,打开autoit的script to exe工具,将步骤3的au3文件转为换exe文件
5.打开jmeter,一次添加计划、线程组->BeanShell Sampler,在beanshell中添加调用exe的java代码
Runtime rn = Runtime.getRuntime(); Process p = null; try { p = rn.exec("\"C:/callout1008622.exe\""); } catch (Exception e) { System.out.println("Error exec!"); }
6.保存后,启动jmeter,运行通过
******************************************************************************************************************************************
作者:乔叶叶
博客地址:http://www.cnblogs.com/qiaoyeye/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
******************************************************************************************************************************************
作者:乔叶叶
博客地址:http://www.cnblogs.com/qiaoyeye/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
******************************************************************************************************************************************