csdn博客:http://blog.csdn.net/qwentest

我是如何使用QTP去测试的(三)

上一篇 / 下一篇  2010-08-30 15:15:54 / 个人分类:Bug那些事儿

上接http://www.51testing.com/index.php?uid-287227-action-viewspace-itemid-21945051Testing软件测试网nu0| S2Y

4验证loginCase文档中login_004login_00951Testing软件测试网9?w$t){E

For i=2 to 7

7|;H2S0J$Ba5?6}@0

        读取data中,login的数据

j Sz6sX;sV,]O%aL0

        Dim username,password,expected

$}'R:V;x S7?BT9P8[Z0

        username=ReadExcelCell(dataPath, "login", i, 1)

|x;\y5]$^0

        password=ReadExcelCell(dataPath, "login", i, 2)

!i/v;vEmd0

        expected=ReadExcelCell(dataPath,"login",i,3)

4[p{tB_0

执行登录操作,将读取到的username参数化给下面的数据51Testing软件测试网-S {/c|5P)p%I9YX

        Browser("Browser").Page("在线考试系统").Frame("main").WebEdit("username").Set username

Z;\d"E ~Fr n d{0

        Browser("Browser").Page("在线考试系统").Frame("main").WebEdit("pwd").Set password

-U'j7\I"s-[WwS1l0

        Browser("Browser").Page("在线考试系统").Frame("main").WebButton(" ").Click51Testing软件测试网2Q:{*t;jc"w:kc n~

        判断登录是否成功的文本字符51Testing软件测试网 ?1Y5h^(}.c P

        popok=Browser("Browser").Page("在线考试系统").Frame("left").WebElement("考生姓名:123   态:已登录").Exist(3)51Testing软件测试网sM*Q}$A5F.U0}2i

        popno=Browser("Browser").Page("在线考试系统").Frame("main_2").WebElement("").Exist(3)

0La3WHX3A0@;p0

        依据期望结果进行判断

!I#Z'zxl wm,n @0

  If expected="ok" Then51Testing软件测试网7z;MC8`;X7y@

                  If popok Then

1^ z q*y#EUvb0

                    '将数据源中的期待结果写为pass51Testing软件测试网e\A"g[$@5~ s%B

                           Write_Excel dataPath,"login",i,"D","Pass"51Testing软件测试网1Gw%o7eX-[2m

                           '将此结果在测试用例中进行体现51Testing软件测试网!}#j+tsS)F} cT4tm7gI6G

                           Write_Excel casePath,"login",i+3,"D","Pass"

gghnH.V3]0

                           '返回登录界面,执行下一轮数据的操作

QAs|7hO0

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【注销登录】").Click51Testing软件测试网\i`mE s V(nG

                           Browser("Browser").Dialog("Microsoft Internet Explorer").WinButton("确定").Click51Testing软件测试网5Ysp b#z(U

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click

A?6~2}8Tp*lJ&bP@#\0

                  else51Testing软件测试网4Wq9GF H`~W1_

                            '如果出现错误,则截图并保存到指定文件夹中51Testing软件测试网g6ceZV_8W3U

                           QTP_Capture capturePath,"login_"&i+351Testing软件测试网/l2p2j q6M2k

 

C'hl'kB(EUrU0

                          '将数据源中的期待结果写为fail51Testing软件测试网^`#`(} [I;K

                           Write_Excel dataPath,"login",i,"D","Fail"51Testing软件测试网Br,EF7[2z:G-QUY

                          Write_Excel dataPath,"login",i,"E","正确用户名和密码登录失败"

7N f2Sb%r?:dV:oE0

 51Testing软件测试网a'b5KOy V"p)[2u aL

                            '将此结果在测试用例中进行体现51Testing软件测试网'y5@/g,]%s)k~:fo[

                           Write_Excel casePath,"login",i+3,"D","Fail"51Testing软件测试网:t)c H^ PG&N

                           Write_Excel casePath,"login",i+3,"E","正确用户名和密码登录失败"51Testing软件测试网/Yfyf$R~h){6~~1r

 51Testing软件测试网;e1[-S'` hYT6O

                           '出错后,重新进入登录界面

&O3\:d3bw5yP(`,r0

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click51Testing软件测试网0t3g9s.sR8s G^

                  End If51Testing软件测试网K]%kp&RRis7kl_z

        else

]_ r-f:ON6Y0

                  If popno Then

7TZg,F%Dtf0

                           'msgbox "no"51Testing软件测试网L*met6@KA

                           '将数据源中的期待结果写为pass51Testing软件测试网$f o]f(|9i t TAg

                           Write_Excel dataPath,"login",i,"D","Pass"51Testing软件测试网 tnJ!mJ#D3dN/`

                           

O'ID rn)_ zZwF0

                            '将此结果在测试用例中进行体现51Testing软件测试网a`r@P1z {-S? F

                           Write_Excel casePath,"login",i+3,"D","Pass"51Testing软件测试网Jo:u/y+sl*^9~'?L

                           ‘pass后返回登录界面,继续执行下一轮操作51Testing软件测试网$c+D)t\6A UX

                           Browser("Browser").Page("在线考试系统").Frame("main_2").WebButton("返回上一页").Click51Testing软件测试网:{1f*l DJ3\ I

                  elseif popok then

nT(]%Bu9A!h:A0W6Z0

                            '如果出现错误,则截图并保存到指定文件夹中51Testing软件测试网;z9v:E\\?0p:C(WmZ

                     QTP_Capture capturePath,"login_"&i+351Testing软件测试网RL9wNQj

                           51Testing软件测试网 C0L)?3{ez-XR

                     '将数据源中的期待结果写为fail51Testing软件测试网 z;A*x f.d6F L+e

                           Write_Excel dataPath,"login",i,"E","错误用户名或密码,登录成功"51Testing软件测试网 tc HH |7P

                           51Testing软件测试网/X ^/r1fW&gP4k

                           ' '将此结果在测试用例中进行体现

V$lD2AV G0

                           Write_Excel casePath,"login",i+3,"E","错误用户名或密码,登录成功"

6KT(xm8m)v3} ?;xn0

 51Testing软件测试网$u O,ed\\,C4|

                           '返回登录界面,继续验证相关数据51Testing软件测试网6ivMAtO+P/V/J2u

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【注销登录】").Click

DI-T\h V J t0

                           Browser("Browser").Dialog("Microsoft Internet Explorer").WinButton("确定").Click51Testing软件测试网!|oqQ7[(}

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click51Testing软件测试网0a^2kF0X+w-x.tK/k

                  else51Testing软件测试网xu^M)b

                            '如果出现错误,则截图并保存到指定文件夹中

r#I^L1Yj/X"b0

                           QTP_Capture capturePath,"login_"&i+351Testing软件测试网-_,c+M.bp

                           

K:UA.l5o$En0

                           '将数据源中的期待结果写为fail

!m!DB Z VM|0

                           Write_Excel dataPath,"login",i,"D","Fail"51Testing软件测试网Z4`EV8b(c*G

                       Write_Excel dataPath,"login",i,"E","错误数据,但提示语不正确"

i5j?&k,n0o0

 

KM%\m O7gVKo2V[rN0

                            '将此结果在测试用例中进行体现51Testing软件测试网a4x_8rt1})u&E"l

                           Write_Excel casePath,"login",i+3,"D","Fail"51Testing软件测试网aY8D%|^4c

                           Write_Excel casePath,"login",i+3,"E","错误数据,但提示语不正确"51Testing软件测试网1ODySs%wR+h w-W

                           '出错后,重新进入登录界面51Testing软件测试网.yw-D8YNP{v

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click51Testing软件测试网,?'X6{Xf7Z

                  End If51Testing软件测试网VC)Y.yB*Z*s#O

 End If51Testing软件测试网lj0AD$j6PO#h2kkna

Next

R;_k0A-cN`@0

D、执行脚本后,关闭网页和发送相关文档到相关人员的邮箱之中

(O$Q6r&Z6\0

'执行完之后,关闭网页51Testing软件测试网l1m/A@[

Browser("Browser").Close

L` f_S'r J D0

 51Testing软件测试网 } w vV| t0@

'执行完此模块的测试后,将测试结果发送到指定的邮件之中

o+BfZAU1@0

Dim Body '邮件的内容51Testing软件测试网|].xJ0fr;?0n-p6p ]T%N

Dim sendto'收件人的地址

BV4C6x i0ID1{0

Dim subject '邮件主题51Testing软件测试网&^2O:l$@,Fw,mL&?4D Y

Body="Hi:"&vbCrLf&"此文件为本次自动化测试Case结果。请查收!谢谢!"&vbCrLf&vbCrLf&"from qwen"&vbCrLf&Now()

c)eD)j$s,f0

sendto="wen.qingshan@byd.com"51Testing软件测试网OpR2bQ6c Z

subject=now()&"自动化测试的结果"

n2\Q-|?1\0

SendMail sendto,subject, Body, casePath51Testing软件测试网pf8Le]1al$pE

一直以来不清楚大家是怎么去使用QTP测试的,甚至也不太清楚我这么去做是否能称得上算一个QTP的框架,不过我就是这样使用QTP去做测试的。最后,十分感谢您能够有耐心地看到这里,谢谢。51Testing软件测试网$I$u*Vsb2T{

另外,不知道是不是因为51这个发表日志框将回车后剩余的空格也认成字符了, 一次发表所有内容老被截断,这点挺另人晕的.

*dNM:OaFI4k9zb0

 51Testing软件测试网!b'UQ^.@L*N(I1L

作者:文青山

+Hr.gQ e'gY3D0

2010-8-30

3X5n HJR1Y)s6D3n2}8H0

TAG:

 

评分:0

我来说两句

Open Toolbar