【GUI】LoadRunner的Controller定时执行
玩玩的,很好玩不是么,工作就是要好玩,否则还工作个屁啊。
输入的参数依次为年月日小时分钟秒毫秒,至少输入前四个,
当定时器起作用后
可以自动的寻找LR的Controller窗体,
找到后自动点击Start按钮,
然后就自动执行性能测试了,
如果还有临时文件覆盖确认窗体出现,
也会顺便点掉它确保执行顺利。
require 'rubygems'require 'win32ole'require 'pp'p "Arguments:"+ARGV.inspectp("[useage]:LRControllerTimer.rb year month day hour [min=0] [sec=0] [usec=0]");exit(-1) unless ARGV.size > 4$start_at = Time.now.to_i$autoit = WIN32OLE.new("AutoItX3.Control")#~ pp $autoit.ole_func_methods#~ pp $autoit.ole_get_methods#~ pp $autoit.ole_put_methods#~ Time.local(year,month,day,hour,min,sec)$timer_at = Time.local(*ARGV).to_iwhile(true) Time.now.to_i - $timer_at > 0 ? break : nilendwhile($autoit.WinActivate("Mercury LoadRunner Controller - DryRunScen.lrs - [Design(3)]") == 0) sleep(30) if($start_at-$timer_at > 5*60)then #~ p ("请启动LR控制器!") p ("PLZ Start LR Controller") exit(-1) endendif($autoit.ControlClick("Mercury LoadRunner Controller - DryRunScen.lrs - [Design(3)]","","4957","left","1") == 1) then #~ p ("点击Design启动按钮成功") p ("Success to click Design Start Button") if($autoit.WinWaitActive("LoadRunner Controller","",10) == 1) then #~ p ("找到调临时文件提示框") p ("Find the temp file overwrite confirm window.") if($autoit.ControlClick("LoadRunner Controller","","6","left","1") == 1) then #~ p ("点击覆盖临时文件确认按钮成功") p ("Success to click temp file overwrite confirm(Yes).") else #~ p ("点击覆盖临时文件确认按钮失败,请确认原因") P ("Fail to click temp file overwrite confirm(Yes).") end else #~ do nothing end #~ p ("邮箱性能测试自动化执行开始") p ("LR Controller Automate Testing is running.")end