QTP tutorial 笔记

上一篇 / 下一篇  2012-09-11 10:06:47 / 个人分类:QTP

P15

Introducing Quicktest:

Benefits: Fast Reliable Repeatable Programmable Comprehensive Reusable


Testing Process:

1.Analyzing your application

to determine what your testing needs.

  • What are your application's development environment?
  • What business processes and functionality do you want to test?
  • Consider how to divide these business processes into small units.

2. Preparing the testing infrastructure

determine resources are required and create these resources accordingly.(Includes shared objects repositories, function libraries)

configure QuickTest settings so that QuickTest will perform. the tasks you need, such as Report.


3. Building yourtests and adding steps to them

 Create one or more empty tests and add them tocreate the testing skeletons. Associate object repositories with relevantactions, and associate your function libraries with relevant test, so that youcan insert steps using keywords.


4. Enhancing yourtest

Insertingcheckpoints into your test lets you search for a specific value of a page,object, or text string, which helps you determine whether your applicationswith multiple sets of data.

Adding logic andconditional or loop statements enables you to add sophisticated checks to yourtest.

 

5. Debugging,running, and analyzing your test

To ensure that itoperates smoothly and without interruption.


6. Reporting defects


P28

Creating an action

Each QuickTest test comprises calls to action.

An internal action is an action that is stored in the local test.

An external action is a referenced call to an action that is stored in a different test

P29

When you insert a call to a new action, it is reusable by default, enabling you to insert calls to the action from any test

P30

1. Start QuickTest and open a new test.

Start-->Programs--> QuickTest Professional

Confirm that Web Add-in is selected, and clear all other Add-ins.

Click OK to close the Add-in Manager and open QuickTest.

  • Add-ins are loaded by selecting Help>About QuickTest Professional.If Web add-in was not loaded, restart the quicktest
  • If the add-in manager does not open when starting QuickTest,Choose Tools>Options. In General tab, select Display Add-in Manager opens.

2. Rename Actions 1 so that it has a logical name.

a.    Ensurethat the Test Flow pane is displayed.

View > Test Flow

b.   Renanethe action as “Login”

3. Create a newaction named “FlightFinder”

a. ChooseInsert>Call to New Action or click the Insert Call to new Action button.

b. Enter name as “FlightFinder”

4. Create calls toadditional actions

Refer to Step 3

SelectFlight andBookFlight

5. Save your test.

Create folder asTutorial

Save file asMercuryTours

Note:If a test haschanged and it was not saved yet, the test name in the title bar contains anasterisk.

Different Ways to Insert Calls to Actions

1.    Edit> Action >Split action or use the split action button

This option divides an existing action into two separate actions at the step you specify.

2.    Insert>Call to Copy of action or right click an action and choose insert call to copy of action.

This action inserts a copy of anexisting action in your test. The action is not linked to the source test from which you copied it.

3.    Insert>Call to Existing action or right-click an action and choose Insert Call to Existing Action.

 

P35

Create Object Repositories

l  Test Object and Run-time Objects

l  Shared Object repositories.

Object repositoryis a storehouse for the test objects used in your test.

QuickTest uses the information it learns to uniquely identify the run-time objects in yourapplication.

Object repositories can also includecheckpoint andoutput value objects.

Run-time objects are created and maintained during a runsession by the object creator. During a run session, QuickTest performs the specified test object method on the run-time object. Runtime object not storedin an object repository, as they are available only during the run session.

P36

shared object repository contains test objects can be usedin multiple actions. This versatility makes it the preferred repository typefor storing and maintaining test objects. By associating a shared objectrepository with an action, you make the test objects in that repositoryavailable for use in the action.

 

local object repository store test objects that can be usedin one specific action.

It is useful forbacking up your test objects, or for learning one or several object.

 

P37

Learning objects in your application

1. Start QuickTest

Making sure thatonly the Web add-in is loaded.

2. Open the test

3. Set the learnsettings for QuickTest

l  Choose Automation > Record and RunSettings. The Record and Run Settings dialog box opens.

l  In the web tab, select Open the following address when a record or run session begins

l  Confirm that the URL in the first box iscorrect and in the second box, choose a browser on which to run your testsession.

l  Confirm that “Do not record and run onbrowsers that are already open” and “Close the browser when the test closes” areselected.

4. Open theMercury Tours Web site

http://newtours.demoaut.com

 

5. View the properties and operations for someof the objects in the Mercury Tours Web site.

l  Choose Tools > Object Spy

l  Keep Object Spy on top while spying checkbox is selected.

 

6. Start the Navigate and Learn process by setting up the Define Object Filter.

l  Choose Resources > Object RepositoryManager.

l  Choose Object > Navigate and Learn.

l  Click the Define Object Filter button.

l  Select the Selected object types radio  button and click Select.

l  Click the Clear All button to clear all ofthe check boxes. Then select the Edit Box and Image check boxes and click OK.This instructs QuickTest to learn only the objects that are needed for yourtest and add them to the object repository

 

7. Learn the selected object types from the Mercury Tours Web site Welcome page.

To learn all of the objects in web site and add them to a shared object repository.

8. Learn the selected object types from the Mercury Tours Web site Welcome page.

9. See what QuickTest learned about one of the objects

10. Save theobject repository. File> Save

11. Associate theobject repository with Login action

Switch to QTP window and open the Resources pane (View>Resources)

Right-Click Loginaction and choose Associate repository with action.

12. Save your test

 

P46

Using multiple object Repository

1. Learned all theobject on sign in page and Flight Finder page

2. Associate theobject repository with corresponding action

 

P51

Creating Functions and Function Libraries

A function is aset of coded steps that perform. a particular task.

Create a function

1. Start QuickTestand create a new function library

File > New > Function Library

‘The followingfunction checks whether a date string (dateStr)
‘has 10 charactersrepresenting MM/DD/YYYY
Functioncheck_data_validity( dateStr )
Dim firstSlashPos, secondSlashPos
Dim mmPart, ddPart, yyyyPart
firstSlashPos =inStr( dateStr , "/" )
secondSlashPos = inStrRev( dateStr, "/" )
If ( firstSlashPos <> 3 or secondSlashPos<> 6 ) Then
reporter.ReportEvent micFail,"Format check","Date string is missing at least one slash ( / )."
check_data_validity = False
Exit function
End If
mmPart = mid( dateStr, 1,2 )
ddPart = mid ( dateStr, firstSlashPos+1, 2 )
yyyyPart = mid( dateStr, secondSlashPos +1 , 4 )
 
If mmPart > 12 Then
reporter.ReportEvent micFail, "Format Check", "The month value is invalid. It exceeds 12."
check_data_validity = False
Exit function
End If
If ddPart > 31 Then
Reporter.ReportEvent micFail, "Format Check", "The date value is invalid. It exceeds 31."
check_data_validity = False
Exit function
End If
If yyyyPart < 2000 Then
reporter.ReportEvent micFail, "Format Check", "The year value is invalid. (Prior to 2000)"
check_data_validity = False
Exit function
End If
check_data_validity= True
End Function

 

3. Save thefunction library

 File> Save as “CheckDateFunction.qfl”

Close

 

P54

Associatingthe function library with your test

1. Open the action

2. Associatethe CheckDateFunction.qfl with the Mercury Tours test.

l  View> Resources

l  Right-click the Associated FunctionLibraries node and choose Associate Function Library

l  Locate and select the CheckDateFunction.qflfunction library and click Open. Click Yes in the Automatic Relative PathConversion dialog box.

3. Verify that the functionlibrary file is associated with your test.

Choose Resources > Associate Function Libraries and verify that CheckDateFunction.qflis listed in the menu.

4. Save the test

 

 

P57

Creating a Test

Preparing to create a test

1. Clear autocomplete option

2. Close all brower

3. Setthe proper Web Page/Frame. options. Open QuickTest, choose Tools > Options andclick the Web > Page/Frame. node. In the Create a new Page test object for area,select Different URLs or a change in data transfer and select the first fourcheck boxes. ???

 

Add steps to the login action

1. Start QTP and open saved test

2. Open the login action in keyword view

 Click the Test Flow tab todisplay the Test flow pane. (View> Test Flow)

 Double-click the login action

3. Add the first step needed to login to web site

l  Insert > New Step.

l  Select Object from repository to open theSelect Object for Step dialog box and expand the test object tree.

l  Select userName and click OK.

l  In the Value cell, enter “tutorial”.

[[[Browser("Welcome: MercuryTours").Page("Welcome: MercuryTours").WebEdit("userName").Set "tutorial" ]]]

4. Add next step

l  Insert > New Step.

l  Select password from the Item list.Password need to be encoded

l   Click in the Operation cell to display andthen click the down arrow to display the list of available methods for theselected test object. Select SetSecure from the list. This method enables theuse of encrypted text. Now you need to generate the encrypted text and insert itin the Value cell.

l   Generate an encoded password (Start >Programs > QuickTest Professional > Tools > Password Encoder)

6. Insert the last step in the login action (Click onSign in button)

7. Save the test

 

Dividing an action into twoactions

1. Select the page where you want the second action tobegin.

2. Split the test into two actions

l  Edit > Action > Split Action

l  Enter all fields

3. Click on OK button

4. Click Save button

 

P83

Runningand Analyzing Tests

Part1 Run

1. Start QuickTest and open the MercuryTours Test

2. Confirm that all images are saved to the result

Choose Tools > Options or click theOptions button, and then click the Run > Screen Capture node. In the Savestill image captures to results option, select Always. Click OK to close theOptions dialog box.

3. Start running your test

       Click Runà Select run result folder à Click OK to close

 

Part 2 analyzing result

Result tree + Result detail

Click “expend” to display all of the steps performedon the flight finder page. And in test result window contains three panes,

              1.the result tree, with one step highlighted

              2.the test result details of the highlighted step

3. the still image capture pane, showing ascreen capture of the Web page on which the step was performed.

 

Creating checkpoints andusing functions

A checkpoint verifies that expected information isdisplayed in your application which the testing is running.

 

Standard

Checkpoint

Checks values of an object’s properties.

Check that a radio button is

selected.

Image

Checkpoint

Checks the property values of an

image.

(This checkpoint type is inserted by

selecting the Standard Checkpoint

option and then selecting to check

a Web Image object.)

Check that the image source

file is correct.

Table

Checkpoint

Checks information in a table.

(This checkpoint type is inserted by

selecting the Standard Checkpoint

option and then selecting to check

any table object.)

Check that the value in a

table cell is correct.

Page

Checkpoint

Checks the characteristics of a Web

page.

(This checkpoint type is inserted by

selecting the Standard Checkpoint

option and then selecting to check

a Web Page object.)

Check how long a Web page

takes to load or if a Web page

contains broken links.

Text

Checkpoint

Checks that a text string is

displayed in the appropriate place


相关阅读:

TAG: QTP qtp

 

评分:0

我来说两句

日历

« 2024-03-27  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

我的存档

数据统计

  • 访问量: 11947
  • 日志数: 13
  • 建立时间: 2012-09-11
  • 更新时间: 2012-09-26

RSS订阅

Open Toolbar