Preparing to Record a TestBefore 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:
Recording a TestIn 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.
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.
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.
Choose Automation > Record or click the Record button. The Record and Run Settings dialog box opens.
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.
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.
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.
Change the following selections:
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.
Click CONTINUE to accept the default flight selections. The Book a Flight page opens.
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.
Click BACK TO HOME. The Mercury Tours home page opens.
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.
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. |
下面这个例子中,主要是录制在Mercury Tours网站中预订从New York到San Francisco的机票的过程。
在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可以打开一个新的空白脚本。
注意:如果不能打开Add-in Manager,选择Tools > Options。在General页,选择Display Add-in Manager on startup。再此重启QuickTest之后,Add-in Manager就会打开了。
选择Automation > Record或者点击Record按钮。将会弹出Record and Run Settings对话框。
确认选定了Do not record and run on browsers that are already open和Close the browser when the test closes。
这样的设置可以避免脚本录制过程中录制到一些其他的应用程序(如突然弹出的e-mail)。 点击OK。 QuickTest开始录制脚本,浏览器打开Mercury Tours站点。 |
在User Name和Password输入框中输入注册的用户名和密码。 点击Sign-In。 打开Flight Finder页面。
更改如下的字段:
其他字段保留默认值,点击CONTINUE进入Select Flight页面。 注意: 在选择数据的时候,最好是点击下拉框,在列表中选择一个新的输入。这是因为QuickTest只会记录下有变更的操作。如果默认了当前的日期,脚本录制可能会有问题。 在录制输入日期步骤的时候,不要点击View Calendar按钮,因为点击该按钮后,会打开一个Java-based的日历。因为没有加载QuickTest Java Add-in,所以脚本中不会录制到这个操作。 要查看加载的add-in,可以点击Help > About Quick Test Professional。更改可用的add-in 需要重启QuickTest Professional。
其他字段保留默认值,点击CONTINUE进入Book a Flight页面。
在Passengers 和Credit Card输入信息(红色标注处)。(允许任意输入) 在Billing Address选择Ticketless Travel。 点击页面下方的SECURE PURCHASE按钮进入Flight Confirmation页面。
点击BACK TO HOME回到Mercury Tours主页。
在QuickTest中找到Testing工具栏,点击Stop 停止录制。 目前为止已经预订了一个假象的从New York飞往San Francisco的商务仓机票。QuickTest记录下了从点击Record到点击Stop在浏览器中的所有操作。
点击File > Save 或者点击Save 按钮,弹出保存对话框。 创建可以保存脚本的文件夹,输入脚本的名称,确认后点击Save按钮。 注意:如果某个脚本改变了但是还没有保存,标题栏上所显示的脚本的名称上会显示一个*。 |