jmeter结合autoit操作windows程序

Posted 乔叶叶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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,运行通过

以上是关于jmeter结合autoit操作windows程序的主要内容,如果未能解决你的问题,请参考以下文章

运维开发windows下的自动化脚本语言autoit

selenium 基于Autolt工具对于Windows窗口上传文件操作

如何使用 AutoIt 或 Windows UI 自动化单击应用程序中的按钮

重复登录Windows远程桌面-Autoit脚本

如何避免windows系统开机启动每次都弹出AutoIt报错

关于IE9中webdiriver使用autoit上传文件报错