这两天QTP出错记录

1. 作关键字驱动脚本的一个小试验

Browser(“Find a Flight: Mercury”).Sync
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebRadioGroup(“tripType”).Select “oneway”
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebList(“passCount”).Select “1″
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebList(“fromPort”).Select “London”
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebList(“fromMonth”).Select “March”
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebList(“fromDay”).Select “27″
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebList(“toPort”).Select “New York”
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebList(“toMonth”).Select “April”
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebList(“toDay”).Select “21″
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebRadioGroup(“servClass”).Select “First”
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).WebList(“airline”).Select “No Preference”
Browser(“Find a Flight: Mercury”).Page(“Find a Flight: Mercury”).Image(“findFlights”).Click

 

第2行后面“oneway” 第一次写成“Oneway”了
注意大小写敏感
出错信息是 没有包含在Object‘s  item collection。

2. 作基本的脚本录制回放
Browser(“Welcome: Mercury Tours”).Page(“Welcome: Mercury Tours”).Sync
Browser(“Welcome: Mercury Tours”).Page(“Welcome: Mercury Tours”).WebEdit(“userName”).Set “jaunty”
Browser(“Welcome: Mercury Tours”).Page(“Welcome: Mercury Tours”).WebEdit(“password”).SetSecure “47cd03a82c95a6103581c815c580052e1720fdfd”
Browser(“Welcome: Mercury Tours”).Page(“Welcome: Mercury Tours”).Image(“Sign-In”).Click 10,2

第一行Browser的语句,第一次没有给加载页面的过程加同步点 因为想着第一次 页面load 不需要做前提条件。
后来回放的时候 WebEdit对象“userName” 一直对象disabled.
个人猜测是由于机器太慢load太久 但测试步骤已经开始导致
加入同步点解决。

(页面加载过程也需要同步点。。。汗。。。)
后来在windowsForm程序 开始Launcher的时候 也需要加入同步点,第一次回访出现对象disabled问题
加入同步点后解决。

 

 

3. 描述性编程小实验
Dialog(“Login”).WinEdit(“Agent Name:”).Set “jaunty”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “47d888b608eeba747a9be67b7464720d04f7e08e”
Dialog(“Login”).WinObject(“nativeclass:=Button”, “text:=OK”).Click
Window(“Flight Reservation”).WinMenu(“Menu”).Select “File;Exit”

第三行,第一次忘记在两个属性之间加入空格,导致执行第三行的时候 QTP无法识别下来的动作。无错误信息,就是执行不到下一步!

加入空格解决。

 

4. 脚本运行前对待测程序的保证

If not Dialog(“Login”).Exist Then
 SystemUtil.Run “C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe”
End If

当然最一开始要加入一个语句判断一下所要操作的Object打开了没有。没有的话要打开

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • email
  • LinkedIn
  • Live
  • MySpace
  • RSS
  • StumbleUpon
  • Twitter
  • Yahoo! Buzz
  • 豆瓣
  • 豆瓣九点

Tags: , ,

Leave a Comment