多测师是一家拥有先进的教学理念,强大的师资团队,业内好评甚多的接口自动化测试培训机构!

17727591462

联系电话

您现在所在位置:接口自动化测试培训 > 新闻资讯

QTP的飞机登录描述性编程-自动化测试

更新时间:2022-05-13 09:12:52 作者:多测师 浏览:229

  在QTP中,要先去录制用户名和密码,错误的一次和正确的一次,对于错误所弹出的对话框要进行建立文本的检查点,以便datatable的用例进行比对。用户名和密码要进行参数化,在进行判断。

QTP的飞机登录描述性编程-自动化测试

  Dim url

  url="C:Program FilesMercury InteractiveQuickTest Professionalsamples lightpp light4a.exe"

  if Dialog("text:=Login").Exist(1) then

  OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set DataTable("p_Text", dtGlobalSheet)

  OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Password:").Set DataTable("p_Text1", dtGlobalSheet)

  OptionalStep.Dialog("text:=Login").WinButton("text:=OK").Click

  wait(1)

  else

  如果QTP不能自己打开被测试程序就使用该功能打开

  systemUtil.Run url

  OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set DataTable("p_Text", dtGlobalSheet)

  OptionalStep.Dialog("text:=Login").WinEdit("attached text:=Password:").Set DataTable("p_Text1", dtGlobalSheet)

  OptionalStep.Dialog("text:=Login").WinButton("text:=OK").Click

  wait(1)

  end if

  检查点

  if Dialog("text:=Login").Dialog("text:=Flight Reservations").Exist(2) then

  dim errorinfor,odesc

  set desc=description.Create

  odesc("text").value=DataTable("error",dtGlobalSheet)

  errorinfor=Dialog("text:=Login").Dialog("text:=Flight Reservations").Static(odesc).GetROProperty("text")

  Dialog("text:=Login").Dialog("text:=Flight Reservations").WinButton("text:=确定").Click

  学习一下Reporter方法的用法

  Reporter.ReportEvent micDone,"登陆验证失败,提示信息如下",errorinfor

  OptionalStep.Dialog("text:=Login").close

  wait(1)

  else

  如果用户名和密码正确就进入订票页面

  If Window("text:=Flight Reservation").Exist(10) then

  Reporter.ReportEvent micPass,"登陆验证通过","用户名密码正确"

  Window("text:=Flight Reservation").close

  wait(1)

  Set desc=Nothing

  end if

  end if

  以上内容为大家介绍了自动化测试中的QTP的飞机登录描述性编程,本文由多测师亲自撰写,希望对大家有所帮助。了解更多自动化测试相关知识:https://www.aichudan.com/xwzx/

联系电话

17727591462

返回顶部