分类:
2008-09-09 12:44:36
如果要打开右键菜单,在QTP中可以使用以下函数:
Click [x], [y], [BUTTON]
在QTP的帮助中,对X、Y、BUTTON分别做如下定义:
X:Optional. A Long value. The x-coordinate of the click. Y:Optional. A Long value. The y-coordinate of the click. Tip: You can enter micNoCoordinate for the x and y argument values if you want to enter a value for the button argument without specifying x- and y- coordinates for the click. BUTTON:Optional. A pre-defined constant or number. See the Constants table, below. Indicates the mouse button that performs the click. Default = micLeftBtn |
这是在WEB方式下的定义,在C/S应用程序中定义略有不同:
X:Optional. An Integer value. The x-coordinate of the click. Note that the specified coordinates are relative to the upper left corner of the object. Default = micNoCoordinate (center of the object). Y:Optional. An Integer value. The y-coordinate of the click. Note that the specified coordinates are relative to the upper left corner of the object. Default = micNoCoordinate (center of the object). BUTTON:Optional. A pre-defined constant or number. See the Constants table, below. The mouse button used to click the object. Default = micLeftBtn (0). |
大家都知道点击鼠标有三类操作,分别是左击、右击、中间击。对应这里的BUTTON就有以下几种应用:
micLeftBtn or 0 - The left mouse button.
micRightBtn or 1 - The right mouse button. micMiddleBtn or 2 - The middle mouse button. Example 1: Window("Notepad").WinEditor("Edit").Click 4, 4, micRightBtn Browser("Google").Page("Google").Link("Advertising Programs").Click 5,4, micRightBtn Example 2: |
*这是从网上摘抄的一个例子,楼主kernzhang说如果用了WEB ADD IN ,则需要修改ReplayType,但是我试了直接用Browser("Google").Page("Google").Link("Advertising Programs").Click 5,4, micRightBtn语句也能成功回放,不知道kernzhang为何做如此说,是否有相关的配置,我现在还不知道,以后再慢慢研究。这个例子的下一段是点击右键菜单中第四个菜单操作的脚本*
cur_replay_type = Setting.WebPackage("ReplayType") ' Change replay type to mouse replay.. Setting.WebPackage("ReplayType") = 2 Browser("Google").Page("Google").Link("Advertising Programs").Click 5,4, micRightBtn Setting.WebPackage("ReplayType") = cur_replay_type ' Select the fourth menu item idx=4 Set WshShell = CreateObject("Wscrīpt.Shell") For i = 1 To idx WshShell.sendKeys "{DOWN}" Next WshShell.sendKeys "{ENTER}" Set WshShell = nothing |
在WEB方式下,虽然直接写脚本可以进行回放,但是用录制却不能把点击右键的操作录制下来,不知道为何?