51Testing软件测试论坛

标题: 菜鸟求教,请高人指点QTP报错:“缺少对象: 'WScript'” [打印本页]

作者: xunying    时间: 2015-1-15 09:15
标题: 菜鸟求教,请高人指点QTP报错:“缺少对象: 'WScript'”
以下代码执行后报“缺少对象: 'WScript'” ,但把Set WshShell = WScript.CreateObject ("WScript.Shell")改成Set WshShell = CreateObject ("WScript.Shell")是可以的,后面的
WScript.sleep 1500又是缺少对象WScript
Dim WshShell
Set WshShell = WScript.CreateObject ("WScript.Shell")
WshShell.Run "notepad"
WScript.sleep 1500
WshShell.AppActivate "无标题 - 记事本"
WshShell.sendKeys "H"
WScript.sleep 500
WshShell.sendKeys "A"
WScript.sleep 500
WshShell.sendKeys "P"
WScript.sleep 500
WshShell.sendKeys "P"
WScript.sleep 500
WshShell.sendKeys "Y"
WScript.sleep 500
WshShell.sendKeys "%FS"
WshShell.sendKeys "t"
WScript.sleep 500
WshShell.sendKeys "e"
WScript.sleep 500
WshShell.sendKeys "s"
WScript.sleep 500
WshShell.sendKeys "t"
WScript.sleep 500
WshShell.sendKeys "{.}"
WScript.sleep 500
WshShell.sendKeys "t"
WScript.sleep 500
WshShell.sendKeys "x"
WScript.sleep 500
WshShell.sendKeys "t"

作者: xunying    时间: 2015-1-15 10:22
已解决
作者: lsekfe    时间: 2015-1-15 10:24
xunying 发表于 2015-1-15 10:22
已解决

LZ能否分享下你的解决方案。
作者: xunying    时间: 2015-1-15 14:46
把Set WshShell = WScript.CreateObject ("WScript.Shell")改成Set WshShell = CreateObject ("WScript.Shell")
把WScript.sleep改成wait了
作者: xiaoshi_2011    时间: 2015-1-15 15:04
高手,学习了
作者: 吴素玲    时间: 2015-1-29 16:03
1、是不是没有声明WScript.

作者: wys702a8    时间: 2015-2-7 14:22
QTP不支持WScript.CreateObject
作者: 1421320187    时间: 2015-6-9 10:02
同样的问题




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2