标题: QTP自动化用例中的实际结果和上一条用例结果一样,如何解决 [打印本页] 作者: yanfang84 时间: 2012-11-29 11:02 标题: QTP自动化用例中的实际结果和上一条用例结果一样,如何解决 使用QTP录制了一个注册流程,有邮箱、昵称、密码和确认密码,分别参数化后写入测试用例,用例中有错误的邮箱(如已被注册或者格式不对),在执行其下一条用例时也报同样的错误,就算是注册成功了,也有报这样的错误,请高手指点迷津啊?
脚本代码:
Dim email, email2,urlname,urlname2,pwd,pwd2,dpwd,dpwd2
Dim i
email = datatable("邮箱预期结果",dtLocalSheet)
email2 = datatable("邮箱实际结果",dtLocalSheet)
urlname = datatable("昵称预期结果",dtLocalSheet)
urlname2 = datatable("昵称实际结果",dtLocalSheet)
pwd = datatable("密码预期结果",dtLocalSheet)
pwd2 = datatable("密码实际结果",dtLocalSheet)
dpwd = datatable("确认密码预期结果",dtLocalSheet)
dpwd2 = datatable("确认密码实际结果",dtLocalSheet)
Browser("互动汽车_3互动汽车").Page("互动汽车_3互动汽车").Link("注册").Click
For i = 1 to datatable.GetSheet("Action1").GetRowCount
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").WebEdit("email").Set DataTable("登录邮箱", dtLocalSheet)
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").Output CheckPoint("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网_2")
If email <> email2 Then
Reporter.ReportEvent 1,"错误信息","邮箱预期结果:"+ email +",邮箱实际结果:"+ email2
End If
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").WebEdit("nickname").Set DataTable("站内昵称", dtLocalSheet)
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").Output CheckPoint("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网_3")
If urlname <> urlname2 Then
Reporter.ReportEvent 1,"错误信息","昵称预期结果:"+ urlname +",昵称实际结果:"+ urlname2
End If
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").WebEdit("password").SetSecure DataTable("登录密码", dtLocalSheet)
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").Output CheckPoint("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网_4")
If pwd <> pwd2 Then
Reporter.ReportEvent 1,"错误信息","密码预期结果:"+ pwd +",密码实际结果:"+ pwd
Reporter.ReportEvent 1,"错误信息","确认密码预期结果:"+ dpwd +",确认密码实际结果:"+ dpwd2
End If
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").WebEdit("repassword").SetSecure DataTable("确认密码", dtLocalSheet)
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").Output CheckPoint("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网_5")
If dpwd <> dpwd2 Then
Reporter.ReportEvent 1,"错误信息","确认密码预期结果:"+ dpwd +",确认密码实际结果:"+ dpwd2
End If
datatable.GetSheet("Action1").SetNextRow
Next
Browser("互动汽车_3互动汽车").Page("互动汽车-DRIVE FOR LIFE,爱汽车、爱生活、爱网").WebButton("WebButton").Click