『原创』Loadrunner关于页面检查的几个函数详解
上一篇 / 下一篇 2008-09-24 10:05:21 / 个人分类:测试工具
q-dyG,V1Z ]0环境:
-s%M|.TH)a1X0Loadrunner版本:8.051Testing软件测试网s,S5rI.Q-J;U
自建一个test.html文件:
B4RLJ6kT0<html>51Testing软件测试网.H? QxjW4h%S`
<head>
gyquM
SU8Ur7v W0<meta name="google1" content="google2"/>51Testing软件测试网'ftF:~3op |3p8n5M-L
<title>google3</title></head>51Testing软件测试网+R!`5?.NS@;R&p%v
<body>
{_%~
cW^0google4:<input type="text" name="google5" />
9w1DE%qf{0<input type="submit" value="google6"/><br>
U2_
w]A,OY(F
C0<a href="http://www.google.com/calendar/render?hl=zh-CN&tab=wc" class=gb2>google7</a><br>51Testing软件测试网 I2df
@1U#Z
<img src=http://www.google.cn/intl/zh-CN/images/logo_cn.gif width=200 height=88 border=0 alt="google8" title="Google9">51Testing软件测试网d@1BDw R5~9`%NJJ
<img src=http://www.google.cn/intl/zh-CN/images/logo_cn.gif width=200 height=88 border=0 alt="google8" title="Google9">51Testing软件测试网*rQ9B;XB"y
</body>
6v d1]#d_K^e0</html>
U6y;^Y/FD^F+`0
[
VoKd"ge)]'`0一、web_image_check51Testing软件测试网UU @+vfoh3u
O
bJ*l vbj0语法:51Testing软件测试网}\N.V|v$gm0XD
int web_image_check(const char*CheckName,<List of Attributes>,<"Alt=alt"|| "Src=src">, LAST );
}5|P!GU
d0参数:51Testing软件测试网sLZu{ @
W9og.O'S;I01、CheckName:Check名称。
!l#YcC%y!N gX2K02、List of Attributes:51Testing软件测试网9G:T YA(iO#C$l
支持的属性有:Frame(在多Frame的情况下,定义要查找Frame的范围)。
7xd^)o4B4}*~sD0支持的选项有:51Testing软件测试网#M3Gy"s b0^&~9N
Expect:检查通过的条件,默认为Found
p)AK ~WR$?%s$B0Matchcase:是否区分大小写,默认为no51Testing软件测试网'P;s4m+a)DjSk
Repeat:找到第一个符合条件字符串后,是否还继续搜索,默认为yes51Testing软件测试网!q[&m9lo;_j Tq9R
Report:什么情况下(success、failure、always)显示检查结果,默认always51Testing软件测试网h0PQFG2UYZk
Onfailure:失败(expect的值决定)的情况下,是否继续,默认为Continue on Error。
L1AJBx:~@Y
Y1v4JO03、Alt:图片的ALT标记。51Testing软件测试网4iT^ IkKs
4、Src:图片的SRC标记。51Testing软件测试网{)JM iq%M;w
说明:51Testing软件测试网3K8m0b"r
A*S
D7~;FXW9N&{5@$S01、注意勾上Runtime Settings—Internet Protocl—Preferences—Checks:Enable Image and text check
ir8c1W1NyA02、注意该函数放到web_url后面,且Web_url的Mode须为html(此函数仅仅支持基于HTML的脚本)51Testing软件测试网lj8E,uf-KM%Y6Z!Tk
3、Web_image_check检查指定的图象是否在HTML页面中出现。51Testing软件测试网4w8fuAb0R3_N3j
4、Alt或者Src两者必须有一个在参数列表中出现。如果两项都通过,那么检查成功。51Testing软件测试网%d#B?E"w7u%G
U%w
Dmt
s B4z9[Zj0示例:51Testing软件测试网 F
N"^pBQ&IV
Loadrunner脚本:
/J[ K7W#\[pg2K1o051Testing软件测试网
w7[\*o]F
……
JIIV2k
l%L0@0 web_url("google",
h~3yn;V2r0 "URL=http://127.0.0.1:8000/test.html",
qO+x7`{0 "TargetFrame=",
I?Q.L8vb
Rg#Q,L0 "Resource=0",51Testing软件测试网 a~4tcg]6q9U
"RecContentType=text/html",
L:~E@"E9_
Cj,V h0 "Referer=",
2Y@*^
Q;e0U_"Pq)kw;L0 "Snapshot=t1.inf",
b;s"BnXHE'wZ0 "Mode=HTML",
4g8g)Z*n8i0 LAST);51Testing软件测试网t:X5Oz}eC2Hh
web_image_check("web_image_check",
Hd
T4|^)qf?3Y0 "expect=NotFound",51Testing软件测试网|E#Q5HI+G
s
"Alt=Google8",