睡眠功能的替代方式

时间:2017-07-26 18:23:31

标签: vbscript automated-tests qc

我有VBScript用于传递HP QC中的测试用例。

工作原理: 通过在每个步骤下传递每个按钮的短按键。

挑战: 目前我在两个短信之间使用Sleep。 但有时如果下一个窗口没有加载,我的睡眠时间结束了 脚本会失败。

如何解决这个问题?

Set objShell = CreateObject("WScript.Shell")
WScript.Sleep 5000
n = InputBox("Enter No of TC's","???")
WScript.Sleep 2000
objShell.SendKeys "^ "
WScript.Sleep 4000
For m = 1 To n-1
    objShell.SendKeys "+{DOWN}"
Next
WScript.Sleep 5000
objShell.SendKeys "^%{F9}"
WScript.Sleep 5000 
For x = 1 To n
    WScript.Sleep 8000
    objShell.SendKeys "^r"
    WScript.Sleep 8000
    objShell.SendKeys "{ENTER}"
    WScript.Sleep 3000
    objShell.SendKeys "+{TAB}"
    WScript.Sleep 1000
    objShell.SendKeys "+{TAB}"
    WScript.Sleep 1000
    objShell.SendKeys "+{TAB}"
    WScript.Sleep 1000
    objShell.SendKeys "{ENTER}"
    WScript.Sleep 2000
    For y = 1 To 1
        objShell.SendKeys "As Expected : "
        objShell.SendKeys "{ENTER}"
        objShell.SendKeys "^v"
        WScript.Sleep 2500 
        objShell.SendKeys "^p"
        WScript.Sleep 2500 
        objShell.SendKeys "^p"
        WScript.Sleep 2200
        objShell.SendKeys "^a"
        WScript.Sleep 2200
    Next 
    objShell.SendKeys "^q"
    WScript.Sleep 5000
Next
MsgBox "No. Of TC's executed : " & x-1
WScript.Quit

0 个答案:

没有答案