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-219450

h-A!R6mWFSw$N0

4验证loginCase文档中login_004login_009

qg){3V6]WV+h0

For i=2 to 751Testing软件测试网_-{eB9mk

        读取data中,login的数据

#`W0xp D&aup0

        Dim username,password,expected51Testing软件测试网(^9PJ6K"x

        username=ReadExcelCell(dataPath, "login", i, 1)51Testing软件测试网S mD5HFd

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

}`t3xM0

        expected=ReadExcelCell(dataPath,"login",i,3)51Testing软件测试网:Y8MM;O*t8u`

执行登录操作,将读取到的username参数化给下面的数据51Testing软件测试网+Tz;bF2o

        Browser("Browser").Page("在线考试系统").Frame("main").WebEdit("username").Set username51Testing软件测试网 `Kg MiL4h

        Browser("Browser").Page("在线考试系统").Frame("main").WebEdit("pwd").Set password51Testing软件测试网P*NnzYD1X4k ~

        Browser("Browser").Page("在线考试系统").Frame("main").WebButton(" ").Click51Testing软件测试网'J)Rt|8i g4[$] C}

        判断登录是否成功的文本字符51Testing软件测试网Xchd:e5s;XG:M

        popok=Browser("Browser").Page("在线考试系统").Frame("left").WebElement("考生姓名:123   态:已登录").Exist(3)

&c+Y%rLJ{&A^A0

        popno=Browser("Browser").Page("在线考试系统").Frame("main_2").WebElement("").Exist(3)51Testing软件测试网w&mm9Y WD2M+{Y

        依据期望结果进行判断

U*~l(i(Pn:l$o z0

  If expected="ok" Then51Testing软件测试网$^8|+Nun7CjO

                  If popok Then51Testing软件测试网5SRf {J_"iS

                    '将数据源中的期待结果写为pass51Testing软件测试网\c c.A[ pF'O

                           Write_Excel dataPath,"login",i,"D","Pass"51Testing软件测试网J4A!?vly0WvJ|

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

/xEEW9D i0

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

*y!_.FbA(v\G D6r0

                           '返回登录界面,执行下一轮数据的操作51Testing软件测试网 VJ@o Y2{{6^ ]c Q

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【注销登录】").Click51Testing软件测试网V%z1dL%M-P? OB!?

                           Browser("Browser").Dialog("Microsoft Internet Explorer").WinButton("确定").Click

Xb6vBd9~0

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

*r8Nr.CP| @Q Bx0

                  else51Testing软件测试网+jM7bX8BEL#R

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

c)B8oUqA0

                           QTP_Capture capturePath,"login_"&i+3

5C Z3B-CDQ2I%zCe0

 

U7`o _TKB!?v0

                          '将数据源中的期待结果写为fail51Testing软件测试网 j!s;o5AP;YQ7Y

                           Write_Excel dataPath,"login",i,"D","Fail"

X5h ]&W7|0

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

0zU6\/sI0

 

LS`-B0x r!o3~0

                            '将此结果在测试用例中进行体现51Testing软件测试网#k1s^3|#Qt,Oay

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

O)fMNk)aM0

                           Write_Excel casePath,"login",i+3,"E","正确用户名和密码登录失败"51Testing软件测试网G FJ'SC4o?.C7f

 

0CBmz#I0x0

                           '出错后,重新进入登录界面51Testing软件测试网QKL-Q-r5v

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

E?&d;R9Y?C%K%[O0

                  End If51Testing软件测试网#p.R { O BuD7G3Q.A't

        else51Testing软件测试网{bh#vQkC0["f

                  If popno Then

CK1KH3T!w mC _0

                           'msgbox "no"

yo&aO5i4O \Me0

                           '将数据源中的期待结果写为pass51Testing软件测试网~4I(op8_,V&m

                           Write_Excel dataPath,"login",i,"D","Pass"51Testing软件测试网,CZ2L9J_

                           

:L'O&K2d[C9m0

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

/jH&D FWjs;\0

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

Q,d'KeV+d0u3K0

                           ‘pass后返回登录界面,继续执行下一轮操作

F r E4q+w*g5Guc0

                           Browser("Browser").Page("在线考试系统").Frame("main_2").WebButton("返回上一页").Click51Testing软件测试网~] C!tFx!Zpt

                  elseif popok then

[SaeV}V1S0

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

x3zX,Nd-X0

                     QTP_Capture capturePath,"login_"&i+351Testing软件测试网S$u.cp,\"Sa ZA ]T

                           51Testing软件测试网O6H q6u&ea0A:d

                     '将数据源中的期待结果写为fail51Testing软件测试网j:?'aF/R%p9prTt

                           Write_Excel dataPath,"login",i,"E","错误用户名或密码,登录成功"51Testing软件测试网*Z+B {(}B.p

                           

Wk:V w(mU+`f{i0

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

K1zx$W r K%z_K|0

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

5D.g }4T3V r.[0

 51Testing软件测试网3P+M5GR'ax

                           '返回登录界面,继续验证相关数据51Testing软件测试网4\ PWB'N"eJml

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【注销登录】").Click51Testing软件测试网5Z'vhG?6N;_f [

                           Browser("Browser").Dialog("Microsoft Internet Explorer").WinButton("确定").Click

v#vo _K Zr/R/`8{0

                           Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click51Testing软件测试网[A'Y7l9mVH/I

                  else51Testing软件测试网lm9I&\Q7O*T

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

                           QTP_Capture capturePath,"login_"&i+3

8}Mw#Wvq6Q ?0

                           

`3MS;s d}mrK0

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

*Rr3A+aC~4id0

                           Write_Excel dataPath,"login",i,"D","Fail"51Testing软件测试网ut$rq!g

                       Write_Excel dataPath,"login",i,"E","错误数据,但提示语不正确"51Testing软件测试网(]P z*l1u%~ Zv mF.J

 51Testing软件测试网%sM*DDVl mL

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

)vq&x ~_HT s Z0

                           Write_Excel casePath,"login",i+3,"D","Fail"51Testing软件测试网C z6QG-U*y b

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

Y/h7r1pM\%L0

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

I0`#aC-My5a0

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

shv[;]0

                  End If

3Nu#J g u'`;f6sB8w0

 End If51Testing软件测试网4~;R W3w6r]H8v

Next

r8F A^U{;m,c8T`0i0

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

v2FL-\ mAR&X$^*V9R0

'执行完之后,关闭网页

MA)t4A8q*X`-L sA0

Browser("Browser").Close51Testing软件测试网5mY XD t&N1}Bg

 

}1cA k$c0

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

w:y FQ+Wv%u0

Dim Body '邮件的内容51Testing软件测试网%\DN7M/vU1RG;P

Dim sendto'收件人的地址

_xB[#U0Bl N3i0

Dim subject '邮件主题

#x7ZvH]f0

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

sendto="wen.qingshan@byd.com"51Testing软件测试网Q G9dT#KP.|/r

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

#cfR }#]0

SendMail sendto,subject, Body, casePath51Testing软件测试网A'C6~k}H ^

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

I!hI.\"flL0

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

 51Testing软件测试网d$_aP8J*S3m

作者:文青山

B\-Q!TFu_ V0

2010-8-30

xO,Uz2nU qFT-Q0

TAG:

 

评分:0

我来说两句

Open Toolbar