对产品质量来说,不是100分就是0分

怎样在QTP中打开右键菜单

上一篇 / 下一篇  2007-03-02 17:16:04 / 天气: 晴朗 / 心情: 高兴 / 个人分类:QTP

'i cR5rnl5k/uH0如果要打开右键菜单,在QTP中可以使用以下函数:
$` UP7T Ad2p|)U9C0Click [x], [y], [BUTTON]51Testing软件测试网BHwk:`d"v4n%r

b ~&T[X5M}0在QTP的帮助中,对X、Y、BUTTON分别做如下定义:

$@N,]aJJI^ ?'p0

Q&d3L+PU-| El9{A0X:Optional. A Long value. The x-coordinate of the click.
"bHp6]@6|(n\0Y:Optional. A Long value. The y-coordinate of the click.
2_sZ Iz1_0   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.51Testing软件测试网$Z;^XbOsV1d_H
BUTTON:Optional. A pre-defined constant or number. See the Constants table, below. Indicates the mouse button that performs the click.   Default = micLeftBtn

Go ^)b*H051Testing软件测试网w0x R&C{

这是在WEB方式下的定义,在C/S应用程序中定义略有不同:

Z&t'Ev&b,yG051Testing软件测试网BX)P l ~ {G9s8b

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.  
k$E9mNT7uvE0Default = micNoCoordinate (center of the object).
+D|[.Z_J8@0Y: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.51Testing软件测试网#P%w q'T(V
Default = micNoCoordinate (center of the object).   51Testing软件测试网u m0u5]DpN/l
BUTTON:Optional. A pre-defined constant or number. See the Constants table, below. The mouse button used to click the object. Default = micLeftBtn (0).

#i+T{,a8X&A/i051Testing软件测试网-u{3D eZw[

大家都知道点击鼠标有三类操作,分别是左击、右击、中间击。对应这里的BUTTON就有以下几种应用:

hJ s6bt"t,wQ0

2BT5ud U m4]0

8{+H:p(Sz"F)a0

1}pC#Y&| g%H0micLeftBtn or 0 - The left mouse button.51Testing软件测试网)t:z'z2P y
micRightBtn or 1 - The right mouse button.
:]9v*].y%oi V0micMiddleBtn or 2 - The middle mouse button.  

6~(M sNh?0d nN051Testing软件测试网3p(kwp$z!L

Example 1:

do k9~ E4['Yp(l0

cC W%CO;Tf0Window("Notepad").WinEditor("Edit").Click 4, 4, micRightBtn

x c)^_hj }0

m%Ea]B&HO*Ec0Browser("Google").Page("Google").Link("Advertising Programs").Click 5,4, micRightBtn51Testing软件测试网aiw+u,{2XQ"S

+^q xsW*}0Example 2:51Testing软件测试网UXd5S:oz

1_Ph JFA0*这是从http://www.kernzhang.com/viewtopic.php?t=15网上摘抄的一个例子,楼主kernzhang说如果用了WEB ADD IN ,则需要修改ReplayType,但是我试了直接用Browser("Google").Page("Google").Link("Advertising Programs").Click 5,4, micRightBtn语句也能成功回放,不知道kernzhang为何做如此说,是否有相关的配置,我现在还不知道,以后再慢慢研究。这个例子的下一段是点击右键菜单中第四个菜单操作的脚本51Testing软件测试网)_Jo_0PKU

51Testing软件测试网0SP6w'X'g*_

cur_replay_type = Setting.WebPackage("ReplayType")51Testing软件测试网9^0|!yl\!]/eR"z
' Change replay type to mouse replay..51Testing软件测试网D)S(}2PA
Setting.WebPackage("ReplayType") = 251Testing软件测试网$u;Q h wR2T q1uk q w
Browser("Google").Page("Google").Link("Advertising Programs").Click 5,4, micRightBtn51Testing软件测试网,E3} \,Z9L:S
Setting.WebPackage("ReplayType") = cur_replay_type
D(J Q tT9B(|W:O;b051Testing软件测试网xmTz9u*F
' Select the fourth menu item
3Dz!zWR#W6^ F0idx=4
@g/E VsM9v0Set WshShell = CreateObject("Wscrīpt.Shell")51Testing软件测试网BgQw y
For i = 1 To idx
_3\"aH ?s:{6A0WshShell.sendKeys "{DOWN}"
3K6B{:dp h!b$r0Next
0xxc+T C:wm"P0WshShell.sendKeys "{ENTER}"51Testing软件测试网0?Z!?r [4gJ f"O
Set WshShell = nothing

.n6Tq&Ueu q+m0

t1WA.` L-BZj C0在WEB方式下,虽然直接写脚本可以进行回放,但是用录制却不能把点击右键的操作录制下来,不知道为何?51Testing软件测试网/f H:z/i ~(C;Mt k


TAG: QTP 右键 Click

 

评分:0

我来说两句

Open Toolbar