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

怎样在QTP中打开右键菜单

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

"^)^-}6p+K7z0如果要打开右键菜单,在QTP中可以使用以下函数:
Ur @dY.X[PU0Click [x], [y], [BUTTON]

4W{4Fh|1zbi k"v0

u gR1\&pgb)P0在QTP的帮助中,对X、Y、BUTTON分别做如下定义:

2e;FP&\ }7Q;b3A~.l0m c"Q051Testing软件测试网)^HF&r'J3u1n

X:Optional. A Long value. The x-coordinate of the click.51Testing软件测试网C5G#Lu!H)q2R
Y:Optional. A Long value. The y-coordinate of the click.
z{cc8H2qeC0   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.
snLs;G*_?/a0BUTTON:Optional. A pre-defined constant or number. See the Constants table, below. Indicates the mouse button that performs the click.   Default = micLeftBtn

O)s.O E2}051Testing软件测试网"Cf,g Yoga\%]

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

|Rg!Br)u-][m5sX0

5KI3M2T'`0X: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.  51Testing软件测试网h+z8Q8EK%jT t[
Default = micNoCoordinate (center of the object).51Testing软件测试网#X:}pP/fYQ
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.
T6~ kc3N0Default = micNoCoordinate (center of the object).   
D.n2` I.V*m M(NS^0BUTTON:Optional. A pre-defined constant or number. See the Constants table, below. The mouse button used to click the object. Default = micLeftBtn (0).

a"G ]C c*Ak.`0

[/q1waq0大家都知道点击鼠标有三类操作,分别是左击、右击、中间击。对应这里的BUTTON就有以下几种应用:51Testing软件测试网k E@ F t

%eyn:u a051Testing软件测试网#m7yv+X(}9w ]

51Testing软件测试网:cb6QSP"w/^'S

micLeftBtn or 0 - The left mouse button.51Testing软件测试网*N1Vr eIZvH
micRightBtn or 1 - The right mouse button.51Testing软件测试网0a}8RxF
micMiddleBtn or 2 - The middle mouse button.  

lj@YM0

sLq,D4QY0Example 1:51Testing软件测试网P/xh-PU?5|8p.U%C

51Testing软件测试网$q$HN(W]{.R

Window("Notepad").WinEditor("Edit").Click 4, 4, micRightBtn

-r-wf'?!E.Z;p6A ?L0

O:paA9r,a0F3E0Browser("Google").Page("Google").Link("Advertising Programs").Click 5,4, micRightBtn51Testing软件测试网gs;p)vN o`

51Testing软件测试网uR_s6k`r&W [-w"w

Example 2:

WFT C If051Testing软件测试网.K^&N ?O4K9a

*这是从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软件测试网 V-H\r`A*W9f0J

51Testing软件测试网)\-l#t!VQ;DJZ

cur_replay_type = Setting.WebPackage("ReplayType")51Testing软件测试网R.v@Q^v F zTS
' Change replay type to mouse replay..51Testing软件测试网'TnWH't P'ao
Setting.WebPackage("ReplayType") = 251Testing软件测试网C hBX_4aW!y
Browser("Google").Page("Google").Link("Advertising Programs").Click 5,4, micRightBtn51Testing软件测试网9o:VE9bUxTO4M
Setting.WebPackage("ReplayType") = cur_replay_type
0H/f5c6I Ob A0
!k7Q i-?RKeA'n b0' Select the fourth menu item51Testing软件测试网.r2R LV9[ Vv${$`
idx=451Testing软件测试网8td`!Z@ l`
Set WshShell = CreateObject("Wscrīpt.Shell")
3}O.b oO0For i = 1 To idx
*Xrs9J.O{ A;f4^)b0WshShell.sendKeys "{DOWN}"51Testing软件测试网2e~,wGz8D~Id uoQ
Next
Tgb1@0f,rk f}0WshShell.sendKeys "{ENTER}"
y^%[h:|(x%b0Set WshShell = nothing

%t*cg~1W uZ)s0

v!{.V3y6_sb0R0在WEB方式下,虽然直接写脚本可以进行回放,但是用录制却不能把点击右键的操作录制下来,不知道为何?

#a O_7x9QYO:LI ^0

TAG: QTP 右键 Click

 

评分:0

我来说两句

Open Toolbar