抛弃功能自动化测试,力求把性能测试做到极致!

QTP对cmd操作

上一篇 / 下一篇  2008-07-28 23:36:49 / 个人分类:脚本

使用QTP的键盘操作

'运行CMD
SystemUtil.Run "cmd.exe","","C:\WINDOWS\system32","open"
'输入 ping 51testing.com 字段
Window( "object class:=ConsoleWindowClass" ).Type "Ping 51testing.com"
'输入回车
Window( "object class:=ConsoleWindowClass" ).Type micreturn
'获得CMD里面的内容
txt = Window( "object class:=ConsoleWindowClass" ).GetVisibleText()
'在LOG打印出CMD里面的内容
print txt

使用WshShell 对象

Dim wShell, exec
Set wShell = CreateObject( "Wscrīpt.Shell" )
'"%comspec% 是CMD的环境变量名称
Set exec = wShell.Exec( "%comspec% /C ping 51testing.com" )
print exec.StdOut.ReadAll


TAG: 脚本

 

评分:0

我来说两句

Open Toolbar