[19] QTP study No.4_Recording a test

2007/10/31 16:44

Preparing to Record a Test

Before you begin recording a test, ensure that both your application or Web site and QuickTest are set to match the needs of your test. For the purposes of this tutorial, ensure that:

  • You have registered as a user in the Mercury Tours Web site. For more information, see Using the Mercury Tours Web Site for the First Time.
  • In Microsoft Internet Explorer, you have cleared the AutoComplete option for user names and passwords. For instructions, see Optimizing Browser Settings for Your Test.
  • All browsers are closed before you begin recording.
  • The proper Web Page/Frame options are set. Open QuickTest, choose Tools > Options and click the Web tab. Click the Page/Frame Options button. In the Create a new Page test object for area, select Different URLs or a change in data transfer and select the first four check boxes.

Recording a Test

In this section, you will record the process of making a reservation for a flight from New York to San Francisco on the Mercury Tours Web site.

  1. Start QuickTest and open a new test.
    • If QuickTest is not currently open, choose Start > Programs > QuickTest Professional > QuickTest Professional.

In the Add-in Manager, confirm that the Web Add-in is selected, and clear all other add-ins. Click OK to close the Add-in Manager and open QuickTest.

Note: While QuickTest loads your selected add-ins, the QuickTest splash screen is displayed. This may take a few seconds.

If the Welcome window opens, click Blank Test.

Otherwise, choose File > New > Test, or click the New button down arrow and choose Test.

Note: If a test is already open, clicking the New toolbar button opens a new test.

A blank test opens.

    • If QuickTest is already open, check which add-ins are loaded by selecting Help > About QuickTest Professional. If the Web Add-in is not loaded, you must exit and restart QuickTest. When the Add-in Manager opens, select the Web Add-in, and clear all other add-ins.

Note: If the Add-in Manager does not open when starting QuickTest, choose Tools > Options. In the General tab, select Display Add-in Manager on startup. When you exit and restart QuickTest, the Add-in Manager opens.

  1. Start recording on the Mercury Tours Web site.

Choose Automation > Record or click the Record button. The Record and Run Settings dialog box opens.

    • In the Web tab, select Open the following address when a record or run session begins.

Confirm that the URL in the first box is http://newtours.mercury.com and in the second box, choose a browser on which to run your test session. Microsoft Internet Explorer is the browser used in this tutorial.

Confirm that Do not record and run on browsers that are already open and Close the browser when the test closes are selected.

    • In the Windows Applications tab, confirm that Record and run only on is selected, and make sure that all three check boxes are cleared.

These settings prevent you from inadvertently recording operations performed on various Windows applications (such as e-mail) during a recording session.

Click OK.

QuickTest begins recording, and your browser opens to the Mercury Tours Web site.

  1. Log in to the Mercury Tours Web site.

In the User Name and Password boxes, type the name and password you registered with Mercury Tours.

Click Sign-In.

The Flight Finder page opens.

  1. Enter flight details.

Change the following selections:

    • Departing From: New York
    • On: December 29
    • Arriving In: San Francisco
    • Returning: December 31
    • Service Class: Business class

Click CONTINUE to accept the other default selections. The Select Flight page opens.

Notes:

When selecting the date, you must click the drop-down list, scroll to any new entry, and select it. This is because QuickTest only records a step if the value in the list changes. The tutorial will not work correctly if you accept the currently displayed month or day.

When entering dates while recording this test, do not click the View Calendar button, which opens a Java-based calendar. Your test will not record the date selected using this calendar because the QuickTest Java Add-in is not loaded for this tutorial.

To check which add-ins are loaded, choose Help > About QuickTest Professional. To change the available add-ins for your tests, you must close and reopen QuickTest Professional.

  1. Select a flight.

Click CONTINUE to accept the default flight selections. The Book a Flight page opens.

  1. Enter required passenger and purchase information.

Enter the requiredinformation (fields with red text labels) in the Passengers and Credit Card sections. (You may enter fictitious information.)

In the Billing Address section, select Ticketless Travel.

At the bottom of the page, click SECURE PURCHASE. The Flight Confirmation page opens.

  1. Review and complete your booking.

Click BACK TO HOME. The Mercury Tours home page opens.

  1. Stop recording.

In QuickTest, click Stop on the Testing toolbar to stop the recording process.

You have now reserved an imaginary business class ticket from New York to San Francisco. QuickTest recorded your Web browser operations from the time you clicked the Record button until you clicked the Stop button.

  1. Save your test.

Choose File > Save or click the Save button. The Save dialog box opens to the Tests folder.

Create a folder named Tutorial, select it, and click Open.

Type Recording in the File name field.

Confirm that Save Active Screen files is selected.

Click Save. The test name (Recording) and path are displayed in the title bar of the main QuickTest window.

Note: If a test has changed and is not yet saved, the test name in the title bar contains an asterisk.


2007/10/31 17:45

下面这个例子中,主要是录制在Mercury Tours网站中预订从New YorkSan Francisco的机票的过程。

  1. 运行Quick Test并新建一个测试脚本。
    • 如果当前没有运行Quick Test,选择开始->程序->Quick Test Professional->Quick Test Professional

Quick Test Professional- Add-in Manager窗口,确认Web Add-in已选定,并且取消另外的add-ins的选择。点击Ok关闭此窗口,打开QuickTest

注意:Quick Test在加载add-in的时候需要花些时间,请稍等一下。

如果可以看到欢迎页面,直接点击Blank Test

或者选择File > New > Test,或者点击New后面的三角符号,选择Test

注意:如果已经打开了某脚本,点击New可以打开一个新的空白脚本。

    • 如果 Quick Test已经打开了,在Help > About QuickTest Professional中检查加载的Add-in。如果还没有加载Web Add-in,必须退出重启Quick Test。当Add-in Manager窗口打开后,选择Web Add-in,删除其他add-in

注意:如果不能打开Add-in Manager,选择Tools > Options。在General页,选择Display Add-in Manager on startup。再此重启QuickTest之后,Add-in Manager就会打开了。

  1. Mercury Tours网站录制脚本。(录制之前最好是先熟悉一下这个过程)

选择Automation > Record或者点击Record按钮。将会弹出Record and Run Settings对话框。

    • Web页中选择Open the following address when a record or run session begins。在第一个输入框中输入http://newtours.mercury.com,第二个输入框中选择Microsoft Internet Explorer

确认选定了Do not record and run on browsers that are already open和Close the browser when the test closes
          

    • Windows Applications页,确认选定了Record and run only on,并且清除检查框的选择。

                    

这样的设置可以避免脚本录制过程中录制到一些其他的应用程序(如突然弹出的e-mail)。

点击OK

QuickTest开始录制脚本,浏览器打开Mercury Tours站点。

2007/10/31 17:46
  1. 登录到Mercury Tours网站。

在User NamePassword输入框中输入注册的用户名和密码。

点击Sign-In

打开Flight Finder页面。

  1. 输入flight信息。

更改如下的字段:

    • Departing From: New York
    • On: December 29
    • Arriving In: San Francisco
    • Returning: December 31
    • Service Class: Business class

其他字段保留默认值,点击CONTINUE进入Select Flight页面。

注意:

在选择数据的时候,最好是点击下拉框,在列表中选择一个新的输入。这是因为QuickTest只会记录下有变更的操作。如果默认了当前的日期,脚本录制可能会有问题。

在录制输入日期步骤的时候,不要点击View Calendar按钮,因为点击该按钮后,会打开一个Java-based的日历。因为没有加载QuickTest Java Add-in,所以脚本中不会录制到这个操作。

要查看加载的add-in,可以点击Help > About Quick Test Professional。更改可用的add-in 需要重启QuickTest Professional

  1. 选择一个flight

其他字段保留默认值,点击CONTINUE进入Book a Flight页面。

  1. 输入passengerpurchase信息。

Passengers Credit Card输入信息(红色标注处)。(允许任意输入)

Billing Address选择Ticketless Travel

点击页面下方的SECURE PURCHASE按钮进入Flight Confirmation页面。

  1. 确认并完成booking

点击BACK TO HOME回到Mercury Tours主页。

  1. 停止录制。

QuickTest中找到Testing工具栏,点击Stop 停止录制。

目前为止已经预订了一个假象的从New York飞往San Francisco的商务仓机票。QuickTest记录下了从点击Record到点击Stop在浏览器中的所有操作。

  1. 保存脚本。

点击File > Save 或者点击Save 按钮,弹出保存对话框。

创建可以保存脚本的文件夹,输入脚本的名称,确认后点击Save按钮。

注意:如果某个脚本改变了但是还没有保存,标题栏上所显示的脚本的名称上会显示一个*

posted @ 2008-03-18 15:49  Atine  阅读(558)  评论(1编辑  收藏  举报