51Testing软件测试论坛

标题: 脚本里面如何强制退出当前的ACTION [打印本页]

作者: lijinshui    时间: 2009-7-22 13:04
标题: 脚本里面如何强制退出当前的ACTION
如题,脚本里面如何退出当前的ACTION啊
我想做个判断,如果当前的OBJECT 不存在的话就等待比如说5分钟,时间到自动退出当前ACTION,而不再抛出说找不到OBJECT 啥的
        Dim DialogWin
        Window("Notepad").Activate
        Set DialogWin = Window("Notepad").Dialog("Font")
'DialogWin.WinButton("OK").Click
        If  Not DialogWin.Exist(1) Then
                Call TimeIt(5)
        End If
                If  DialogWin.Exist(1)  Then
                        DialogWin.WinButton("OK").Click
                        else
                        Msgbox "Error Close PLS"
                   ' I want exit  from here
                End If

        i=1/0
Msgbox " 1 " & Err.Number & " " & Err.Description

Function TimeIt(N)
   Dim StartTime, EndTime,iCnt
   StartTime = Timer
   For iCnt = 1 To N
           wait(1)
   Next
   EndTime = Timer
   TimeIt = EndTime - StartTime
End Function
作者: lijinshui    时间: 2009-7-22 13:17
标题: Now is OK
Dim DialogWin
        Window("Notepad").Activate
        Set DialogWin = Window("Notepad").Dialog("Font")
'DialogWin.WinButton("OK").Click
        If  Not DialogWin.Exist(1) Then
                Call TimeIt(2)
        End If
                If  DialogWin.Exist(1)  Then
                        DialogWin.WinButton("OK").Click
                        else
'                        Msgbox "Error Close PLS"
                        ExitAction("Action1")
       
                End If

        i=1/0
Msgbox " 1 " & Err.Number & " " & Err.Description

Function TimeIt(N)
   Dim StartTime, EndTime,iCnt
   StartTime = Timer
   For iCnt = 1 To N
           wait(1)
   Next
   EndTime = Timer
   TimeIt = EndTime - StartTime
End Function

[ 本帖最后由 lijinshui 于 2009-7-22 13:18 编辑 ]
作者: 淡淡风轻    时间: 2009-7-22 14:16
ExitAction
即可
,不需要ExitAction("Action1")
作者: lijinshui    时间: 2009-7-22 15:23
哦, 恩,
可是,如果有好几个Action的话,当前这个Action有问题的话,退出去,还要执行下一个Action呀,
ExitAction可以吗,
作者: marco    时间: 2009-7-22 15:29
Exiting an Action
You can add a line in your script in the Expert View to exit an action before it runs in its entirety. You may want to use this option to return the current value of the action to the value at a specific point in the run or based on the result of a conditional statement. There are four types of exit action statements you can use:

ExitAction. Exits the current action, regardless of its iteration attributes.
ExitActionIteration. Exits the current iteration of the action.
ExitRun. Exits the test, regardless of its iteration attributes.
ExitGlobalIteration. Exits the current global iteration.

lz要学会看帮助
作者: onlonely    时间: 2009-7-22 21:53
楼上的回答经典.很多问题帮助里有答案的.




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