我是如何使用QTP去测试的(三)
上一篇 / 下一篇 2010-08-30 15:15:54 / 个人分类:Bug那些事儿
上接http://www.51testing.com/index.php?uid-287227-action-viewspace-itemid-219450
h-A!R6mW FSw$N04、’验证loginCase文档中login_004至login_009
For i=2 to 7
‘读取data中,login的数据
Dim username,password,expected
username=ReadExcelCell(dataPath, "login", i, 1)
password=ReadExcelCell(dataPath, "login", i, 2)
expected=ReadExcelCell(dataPath,"login",i,3)
‘执行登录操作,将读取到的username参数化给下面的数据
Browser("Browser").Page("在线考试系统").Frame("main").WebEdit("username").Set username
Browser("Browser").Page("在线考试系统").Frame("main").WebEdit("pwd").Set password
Browser("Browser").Page("在线考试系统").Frame("main").WebButton("登 录").Click
‘判断登录是否成功的文本字符
popok=Browser("Browser").Page("在线考试系统").Frame("left").WebElement("考生姓名:123状 态:已登录").Exist(3)
popno=Browser("Browser").Page("在线考试系统").Frame("main_2").WebElement("操作失败").Exist(3)
‘依据期望结果进行判断
If expected="ok" Then
If popok Then
'将数据源中的期待结果写为pass
Write_Excel dataPath,"login",i,"D","Pass"
'将此结果在测试用例中进行体现
Write_Excel casePath,"login",i+3,"D","Pass"
'返回登录界面,执行下一轮数据的操作
Browser("Browser").Page("在线考试系统").Frame("top").Link("【注销登录】").Click
Browser("Browser").Dialog("Microsoft Internet Explorer").WinButton("确定").Click
Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click
else
'如果出现错误,则截图并保存到指定文件夹中
QTP_Capture capturePath,"login_"&i+3
'将数据源中的期待结果写为fail
Write_Excel dataPath,"login",i,"D","Fail"
Write_Excel dataPath,"login",i,"E","正确用户名和密码登录失败"
'将此结果在测试用例中进行体现
Write_Excel casePath,"login",i+3,"D","Fail"
Write_Excel casePath,"login",i+3,"E","正确用户名和密码登录失败"
'出错后,重新进入登录界面
Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click
End If
else
If popno Then
'msgbox "no"
'将数据源中的期待结果写为pass
Write_Excel dataPath,"login",i,"D","Pass"
'将此结果在测试用例中进行体现
Write_Excel casePath,"login",i+3,"D","Pass"
‘pass后返回登录界面,继续执行下一轮操作
Browser("Browser").Page("在线考试系统").Frame("main_2").WebButton("返回上一页").Click
elseif popok then
'如果出现错误,则截图并保存到指定文件夹中
QTP_Capture capturePath,"login_"&i+3
'将数据源中的期待结果写为fail
Write_Excel dataPath,"login",i,"E","错误用户名或密码,登录成功"
' '将此结果在测试用例中进行体现
Write_Excel casePath,"login",i+3,"E","错误用户名或密码,登录成功"
'返回登录界面,继续验证相关数据
Browser("Browser").Page("在线考试系统").Frame("top").Link("【注销登录】").Click
Browser("Browser").Dialog("Microsoft Internet Explorer").WinButton("确定").Click
Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click
else
'如果出现错误,则截图并保存到指定文件夹中
QTP_Capture capturePath,"login_"&i+3
'将数据源中的期待结果写为fail
Write_Excel dataPath,"login",i,"D","Fail"
Write_Excel dataPath,"login",i,"E","错误数据,但提示语不正确"
'将此结果在测试用例中进行体现
Write_Excel casePath,"login",i+3,"D","Fail"
Write_Excel casePath,"login",i+3,"E","错误数据,但提示语不正确"
'出错后,重新进入登录界面
Browser("Browser").Page("在线考试系统").Frame("top").Link("【登录系统】").Click
End If
End If
Next
D、执行脚本后,关闭网页和发送相关文档到相关人员的邮箱之中
'执行完之后,关闭网页
Browser("Browser").Close
'执行完此模块的测试后,将测试结果发送到指定的邮件之中
Dim Body '邮件的内容
Dim sendto'收件人的地址
Dim subject '邮件主题
Body="Hi:"&vbCrLf&"此文件为本次自动化测试的Case结果。请查收!谢谢!"&vbCrLf&vbCrLf&"from qwen"&vbCrLf&Now()
sendto="wen.qingshan@byd.com"
subject=now()&"自动化测试的结果"
SendMail sendto,subject, Body, casePath
一直以来不清楚大家是怎么去使用QTP测试的,甚至也不太清楚我这么去做是否能称得上算一个QTP的框架,不过我就是这样使用QTP去做测试的。最后,十分感谢您能够有耐心地看到这里,谢谢。
I!hI.\"flL0另外,不知道是不是因为51这个发表日志框将回车后剩余的空格也认成字符了, 一次发表所有内容老被截断,这点挺另人晕的.51Testing软件测试网{)Ea C~ S
作者:文青山
2010-8-30
TAG:
csdn博客:http://blog.csdn.net/womengdoushizhongguo
标题搜索
日历
|
|||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
1 | 2 | ||||||||
3 | 4 | 5 | 6 | 7 | 8 | 9 | |||
10 | 11 | 12 | 13 | 14 | 15 | 16 | |||
17 | 18 | 19 | 20 | 21 | 22 | 23 | |||
24 | 25 | 26 | 27 | 28 | 29 | 30 | |||
31 |
我的存档
数据统计
- 访问量: 54696
- 日志数: 104
- 建立时间: 2009-09-10
- 更新时间: 2017-04-30