ctrl01 发表于 2006-3-9 17:19:23

请教各位前辈:为什么我在测试脚本中增加IF判断语句后脚本执行速度就变得很慢啊?

请教各位前辈:
为什么我在测试脚本中增加IF判断语句后脚本执行速度就变得很慢啊?
请教需要在哪里设置或是有什么方法可以优化的。。

能否举一个例子呢?谢谢!!

海龙 发表于 2006-3-9 17:49:23

if语句你判断的什么,对于check point会有超时时间,如果比较的结果不一致,直到超出了超时时间才会继续执行,可以通过缩短超时时间,提高效率

ctrl01 发表于 2006-3-16 17:21:55

谢谢

我是判断是否出现提示窗口。
如:
         Result = WindowVP (Exists, "Caption=提示", "VP=Window Existence")
         IF Result = 1 then
            Window SetContext, "Caption=提示", ""
            PushButton Click, "Text=确定"
            Window SetContext, "Caption=选择数据", ""'如下出现提示窗口后重新手工选择数据
            InputKeys "{RIGHT}{DOWN}"
            PushButton Click, "Text=确定"

amibaren 发表于 2006-3-17 09:56:38

有关验证点的使用方法应该去查看robot的帮助,里面有更详细的介绍,通过一些参数的设定可以解决很多问题,光点那个insert按钮还是不够的。
Establishes a verification point for a window. In this document, a window is a top-level object on the desktop. For example, a dialog box is typically a top-level desktop object.

SYNTAX

Result = WindowVP (action%, recMethod$, parameters$)

Syntax
Element        Description

action%        The type of verification to perform. Valid values:
        CompareDataWindow
Captures the data stored in the PowerBuilder DataWindow and compares it to a recorded baseline. parameters$ VP is required; ExpectedResult and Wait are optional.

Note: This action is only used when the DataWindow object is a Window itself.

CompareImage
Captures a bitmap image of the specified window and compares it to a recorded baseline. parameters$ VP is required; ExpectedResult and Wait are optional.

CompareMenu
Captures the specified window's menu information and compares it to a recorded baseline. parameters$ VP is required; ExpectedResult and Wait are optional.

CompareNumeric
Captures the numeric value of the text of the object and compares it to the value of parameters$ Value or Range. parameters$ VP and either Value or Range are required; ExpectedResult and Wait are optional.

CompareProperties
Captures the object properties information of the Window and all of its children, and compares this to the recorded baseline.
parameters$ VP is required; ExpectedResult and Wait are optional.

CompareText
Captures the text in the title bar of a specified window and compares it to a recorded baseline. parameters$ VP and Type are required; ExpectedResult and Wait are optional.

DoesNotExist
Checks whether a specified window no longer exists at playback. parameters$ VP is required; ExpectedResult, Status, and Wait are optional.

Note: This action cannot be accessed during recording. It must be inserted manually.

Exists
Checks whether a specified window exists at playback. parameters$ VP is required; ExpectedResult, Status, and Wait are optional.

recMethod$        Valid values:
       
If the recognition method is empty, Robot performs the action on the current test context window, as specified by the last SetContext or SetTestContext action.

Caption=$
The text that appears in the window's title bar. 512 characters maximum. The wildcards ? and * are supported.

ChildWindow
Indicates that the window specified by the recognition method is a child of the current context window. It is only used in conjunction with another method. This qualifier is necessary when acting upon windows that are children of other windows.

Class=$
The window's class name.

CurrentWindow
Specifies the windows that is currently active. This recognition method is useful when you want to act upon the active window, even though that may not be the same window each time the command is played back. This recognition method should not be used in conjunction with any other methods.

Level=%
Level is combined with another recognition method when the other recognition method does not uniquely identify the windows. For example, if there are multiple windows with the same caption, and Caption is the recognition method being used. The Level qualifier tells Robot which one of the similarly-identified windows should be targeted for the action, based on the Windows' Z-Order. The first window is assigned "Level=1", the second "Level=2", and so on. Level serves as a clarifier only and is used only after all other methods have been attempted.

Name=$
A name that a developer assigns to an object to uniquely identify the object in the development environment. For example, the object name for a command button might be Command1.

parameters$        Valid values:

ExpectedResult=%
Specifies whether you expect this verification point to pass (baseline result matches playback result) or fail (baseline result does not match playback result). Valid values are PASS
and FAIL.
        Range=&,&
Used with the action CompareNumeric when a numeric range comparison is being performed, as in Range=2,12 (test for numbers in this range). The values are inclusive.

Status=$
An optional parameter used with the Exists action. When used, the status of the window is also verified. The possible values for this parameter are:

NORMAL, MINIMIZED, and MAXIMIZED

Type=$
Specifies the verification method to use for CompareText actions. The possible values are: CaseSensitive, CaseInsensitive and UserDefined.

Value=&
Used with the action CompareNumeric when a numeric equivalence comparison is being performed, as in Value=25 (test against the value 25).

VP=$
The verification point ID. IDs must be unique within a script. Required for all verification points.
        Wait=%,%
A Wait State that specifies the verification point's Retry value and a Timeout value, as in Wait=10,40 (retry the test every 10 seconds, but time out the test after 40 seconds).

COMMENTS

This function returns 1 if the action performed passes or 0 if the action performed fails. See the TestManager log for an explanation of any failures.
Verification points that check for a window's existence are not stored in the datastore and do not appear in Robot's Asset pane.
注意到有个wait的参数Wait=%,%
A Wait State that specifies the verification point's Retry value and a Timeout value, as in Wait=10,40 (retry the test every 10 seconds, but time out the test after 40 seconds).

所以如果你觉得慢的话就在这个函数后面加上wait参数,多长时间检测一次,多长时间后算超时。
比如
result = WindowVP (Exists, "Caption=用户登录", "VP=Window Existence;Wait=1,20;ExpectedResult=Pass")
每秒检测一次这个窗口是否存在,如果20秒还没检测到就算超时,预期结果是pass
你可以把那个超时 的时间设置短一点就可以了。

amibaren 发表于 2006-3-17 09:58:33

还有,在没有超时参数的函数的情况下,可以在playback opition里面调超时时间。
页: [1]
查看完整版本: 请教各位前辈:为什么我在测试脚本中增加IF判断语句后脚本执行速度就变得很慢啊?