安装
51Testing软件测试网p5R;~5Q/v7}6gEn安装Firefox
&|T#gY;M }S0下载
Selenium插件:
http://selenium-ide.openqa.org/ &s/k[&zdEX6Z0将插件拷贝至Firefox/extensions目录下(通常为C:\Program Files\Mozilla Firefox\extensions\)
.QH vB8T"\LZ0重启Firefox,会执行自动安装。
51Testing软件测试网La}_4dU7[`;D|在“Tools”下能够看到“Selenium IDE”插件安装完毕
51Testing软件测试网"XHg2IIgOcI 录制
Selenium html脚本,又称为Selenese,结构清晰简单:
Selenium html脚本,又称为Selenese,结构清晰简单:
6\N1\kA#jo*^0f/P,GX6fJ,}0
KG$Do ~
w/nb0 <html>51Testing软件测试网I E*M i2YU51Testing软件测试网J|%V1Q
w N.K9Y]{
<head>
!K-Q;l:W8u
_KK7j)g+T i0+]8F9i?P0 <meta. http-equiv="Content-Type" content="text/html; charset=UTF-8">51Testing软件测试网+KW1jQ$e51Testing软件测试网(X8ystRmK
<title>Becky02</title>51Testing软件测试网~J4\-D{I Tq3x9y
C_1lw4e2r0 </head>51Testing软件测试网8y"P1}%E)Q51Testing软件测试网voPu!k
<body>51Testing软件测试网3Ec g E+qw{
Ee0{5v+uSl#c{6o*c$b0 <table cellpadding="1" cellspacing="1" border="1">
vj&q x.X Rz5X0#Hm-Jre7HC0 <thead>51Testing软件测试网 U/feRq
k2v'sKAS1lJ0 <tr><td rowspan="1" colspan="3">Test02</td></tr>51Testing软件测试网2NU pf;Sp8s51Testing软件测试网$Z!Wq@;H3EZ
</thead><tbody>
b bq]@$R,T8w:`y0 <tr>
0^ Cz0s
Xv KM?9W0n4R y i9z0 <td>open</td>
;s-K,z$np+fs0we)]3v8T9@Ym0U9s0 <td>http://www.google.com/</td>51Testing软件测试网A$xFpRD
<td></td>51Testing软件测试网.u5R&_+j1xk;y|
!Y*z!~
B6cW0 </tr>51Testing软件测试网I(g8XI G)q
R+K q ]*ej0 <tr>51Testing软件测试网inzf7Tk ^&\/ZX
L3m%c ?#d J z&eS0 <td>type</td>
51Testing软件测试网9YFjsa:J*{U~xh0 <td>q</td>51Testing软件测试网uvTTM:Z7^0m
5rz(D8~
ga_m0 <td>ddddddd</td>51Testing软件测试网&f0Z;l#w/Id+}2HK+L
51Testing软件测试网2S)v.hi$_ </tr>51Testing软件测试网;ZL'@ _]T4E
"BPk$^'H*W0 <tr>51Testing软件测试网B-R!b${ M+b'FR
51Testing软件测试网v^4Yr){s#NX~2w <td>clickAndWait</td>
{Io
kg6aq0U;rnqv0 <td>btnG</td>
\ }+nt@0&G/iq5Z8R5NPMfK r0 <td></td>51Testing软件测试网1|9D F#Z.x,[-v
{)hJ#qi3VO3Ki0 </tr>
51Testing软件测试网Z(b"m_K0a.~ K(GF/\(C Z2pM-V_0 <tr>
51Testing软件测试网-u~K z+\ M)rE0C4iwL7N~NW0 <td>assertText</td>51Testing软件测试网Mv U z m&x8m8U0\
|4E$h$U$Y:^8j0 <td>sd</td>
51Testing软件测试网!N4C(oP.iixFI4oJM?2b8W&T0 <td>Web</td>51Testing软件测试网|7u3oc9\5Td&O
s XG\zmu4gd0 </tr>51Testing软件测试网!Q-P4q!Yx6J\
51Testing软件测试网J0?4N:t uK*X,Y </tbody></table>
51Testing软件测试网!e7J8dYF]X!e!{N;el0 </body>
uVF+uW,U.I0hJ,o.H*~;|Qh2~y&@0 </html>
51Testing软件测试网][2M{6[W*x0I$s\F-L"V-y'AX0
51Testing软件测试网:~T~B*o51Testing软件测试网5~X)uU"OA
51Testing软件测试网t!z5ld-~
U;Li是一个HTML Table:51Testing软件测试网 I:g|%X/hSDh
6W KV7Y"s D051Testing软件测试网4mmlM Br E5X5m
51Testing软件测试网3dAOJXRHTest02
;lC0y4nv/ggthu!y0open
http://www.google.com/51Testing软件测试网l&Pnj)r4I!}u)e(o
51Testing软件测试网7UX
s"z/h~D }iJph"n0type q ddddddd
P4yd*wO0TVZz0clickAndWait btnG
51Testing软件测试网(hb!Q%le-d3QN)OP*t0
51Testing软件测试网+]B3i.[;uHassertText sd Web
6CL9K3fXsh0HTML Table 由三列构成:
9xC3W3NY};j9u0Ti^dM&Yk%{0First Column: Selenium command,命令或断言。51Testing软件测试网^'RWL1I
E1|*V3~ i"W\
B$X&o!?wH0Second Column: Target of command,命令或断言的目标(target)。这里可以用多种受支持的组件定位符中的一种来指定目标。通常使用的是组件的 ID 或名称,但 XPath 和 DOM 定位符也是受支持的;51Testing软件测试网B'D4]3v%o
Third Column: Optional parameter,用于为命令或断言指定参数的值。例如,当使用 type 命令时,这一列可能就是一个文本域所期望的值。
参考对于Selenium的命令,请参考网站资源:
3pv)vU%k*`LY"hC{ g0~&zw0OZV2B0http://release.openqa.org/selenium-core/0.8.0/reference.html51Testing软件测试网Y!\B E#Z?0y
b
]uzI-m/r0 Y1{B
d*^b-o+B0在selenium core的发布包里,也有此reference,下文中即将提到。
51Testing软件测试网Hn\-VOJ-x\
^H}.`KmpH.cf-s0对于
自动化测试来说,任何录制/回放工具得到的脚本,都是要进行修改的,这样能够增加脚本的健壮性。将脚本存为html文件。最终的脚本也要至少回放一遍通过才能算完成,在Selenium IDE中,点播放按钮观看放映。