xunying 发表于 2015-1-15 09:15:44

菜鸟求教,请高人指点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:28

已解决

lsekfe 发表于 2015-1-15 10:24:53

xunying 发表于 2015-1-15 10:22
已解决

LZ能否分享下你的解决方案。

xunying 发表于 2015-1-15 14:46:27

把Set WshShell = WScript.CreateObject ("WScript.Shell")改成Set WshShell = CreateObject ("WScript.Shell")
把WScript.sleep改成wait了

xiaoshi_2011 发表于 2015-1-15 15:04:28

高手,学习了

吴素玲 发表于 2015-1-29 16:03:50

1、是不是没有声明WScript.

wys702a8 发表于 2015-2-7 14:22:18

QTP不支持WScript.CreateObject

1421320187 发表于 2015-6-9 10:02:54

同样的问题
页: [1]
查看完整版本: 菜鸟求教,请高人指点QTP报错:“缺少对象: 'WScript'”