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 and output 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
A 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.
A 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
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 in an application. | Check whether the expected text string is displayed in the expected location in a test object. |
Text Area Checkpoint | Checks that a text string is displayed within a defined area in a Windows-based application. | Check that an area of a dialog box includes text that was entered in another part of the application. |
Bitmap Checkpoint | Checks an area of an application after capturing it as a bitmap. | Check that a Web page (or any portion of it) is displayed as expected. |
Database Checkpoint | Checks the contents of databases accessed by an application or Web site. | Check that the value in a database query is correct. |
Accessibility Checkpoint | Identifies areas of a Web site to check for Section 508 compliancy. | Check if the images on a Web page include ALT properties, required by the W3C Web Content Accessibility Guidelines. |
XML Checkpoint | Checks the data content of XML documents. | Check the content of an element to make sure that its tags, attributes, and values have not changed. Note: XML file checkpoints are used to check a specified XML file; XML application checkpoints are used to check an XML document within a |
Checking Object
This checkpoint verifies the value in the boxcontaining the first name of
the passenger.
1. Start QuickTest
2. Save the test as checkpoint
3. Display the action step on which you want to add astandard checkpoint
a. click the test flow tab to display the test flowpane
b. In the Test flow pane, double-click the BookFlightaction
4. Open the mercury tours application to the book aflight page
5. Create a standard checkpoint
a. Highlight “passFirst0” row
b. Choose Insert> Checkpoint > StandardCheckpoint.
c. In the Name box, enter CheckName as the newcheckpoint name
d. Scroll down and find the attribute named values. Enterthe first name value
e. Select After current step.
f. Accept the rest of the settings as default andclick OK.
6. Save the test
P95
Checking page
The page checkpoint checks that the number of linksand images in the page when you run your test is the same as when QuickTestlearned the objects on which you inserted steps in your test.
1. Locate the page where you want to add a pagecheckpoint.
2. Create a page checkpoint “Insert > Checkpoint> Standard Checkpoint.”
3. In theName box, enter CheckLinks as the new checkpoint name.
4. If all three check boxes are not selected in theType column, select them.
5. Acceptthe rest of the settings as default and click OK
6. Save
P97
Checking Tables
You will add a table checkpoint to check the cost ofthe outbound flight, as displayed in the Book a Flight: Mercury page.
1. Locate the page where you want to add a tablecheckpoint.
In theTest Flow pane, double-click the BookFlight action
Highlightthe passFirst0 step
2. Open the Mercury Tours Web site
Sign in à Enter Flight detailsà Navigate to Book a Flight page
3. Configure QuickTest to record on the open browserpage
4. Create a table checkpoint
a.Highlight 270 in price
b. Clickrecord
c. Insert>Checkpoint> Standard checkpoint
d. Clickthe highlight 270 ------ Checkpoint properties dialog box opens
SelectWebTable: New York to San Francisco and Click OK
EnterCheckpoint name
CheckRow3 column 3
Acceptthe rest setting as default and click OK
5. Stop the recording session
6. Save
Checking Text
In this section, you will add a text checkpoint toyour test to check whether New York is displayed in the Flight Confirmationpage.
1. Locate the page where you want to add a textcheckpoint.
2. Open Confirmation page
3. Create a text checkpoint
Highlight NewYork
Insert> Checkpoint > Text Checkpoint
Clickthe highlighted text string
Enter checkpoint name
Remove San Francisco from summary by clickConfigure button
Accept the rest of the settings as default andclick OK
4. Stop the recording session
5. Make sure the checkpoint is above thehome step
6. Save
Managing checkpoints in Object repository
1. Open the Object Repository window.
Resources > Object Repository
2. Select an Action to view its checkpoints
Runningand analyzing a Test with Checkpoints
Run the script and view the result
P112
Performinga check using a function
1. Start QuickTest and open checkpoint test
Browse to and open theCheckpoint test. ???
2. Save the test as function
File> Save as
3. Display the Select Flight page in TheMercury Tours Web site.
4. Add the12/29/<current year> object to your repository.
aOpen the object repository manager
bBrowse to and open MercuryToursSelectFlight.tsr
cEnable the repository for editing(File> Enable Editing)
d Click the browser window to make it active
e Learn the 12/29/<current year> object
l Fromthe object Repository manager, select Object > Add Objects.
l Clickthe text string
l Makesure that object is highlighted in object selection
l ClickOK
F Save the repository
5. In QuickTest, display the action in whichyou want to add a function.
You want to add a function thatchecks the innertext property values of the date displayed in the SelectFlightaction. In the Test Flow pane, double-click the SelectFlight action.
6. Paste the following in the expert view
departureDate=Browser("Selecta Flight: Mercury").Page("Select a Flight:Mercury").WebElement("12/29/2012").GetROProperty("innertext")
ifcheck_data_validity( departureDate ) then
reporter.ReportEventmicPass, "Date is valid" , departureDate
end if
7. Look at these steps in the keyword view
8. Save the test
9. Start running your test
10. View the result
P117
ParameterizingTests
How the applicationperforms the same operations with multiple sets of data. Alternatively, you cancreate Data Table parameters so you’re your test runs ten times, each timeusing a different set of data.
Defining a Data Table Parameter
1. Start QuickTest and open the Checkpointtest.
Browse to and open the Checkpoint test.
2. Save the test as Parameter
Choose File > Save As. Save the testParameter
3. Confirmation that the Data Table optionis enable
View> Data Table
4. Open the Flight action
5. Select the text to parameterize.
In the fromPort row in the Keyword View,click the Value cell and then click the parameterization icon.
6. Set the parameterization properties
Confirm that the DataTable option isselected
New York will be the first of severaldeparture cities that QuickTest will use during test runs of the application.
Adding Parameter Values to a Data Table
Enter anadditional city and save
Modifying Steps Affected byParameterization
1. Locate thetext checkpoint to modify.
FlightConfirmationà right click FilghtConfirmation: Mercury à selectCheckpoint Properties
2. Parameterizethe text checkpoint
a. Select parameter and click the Parameteroptions dialog box opens
b. In Name box select Departure.
c. Click on OK button
3. Save
Parameterizing an Action
The Global tab isa data sheet whose data is used for the entire test. If five rows of data aredisplayed in the Global table, the test will run five times (five fulliterations). In addition, you can create data sets for each action, using therelevant action sheet. If you parameterize a step using a Data Table parameterfrom a local action sheet and enter five rows of data in that sheet, you candefine that action to run five times within one test iteration. In thissection, you will create a data set for the FlightFinder action to check howthe application handles multiple orders during a single user session.
1. Open theFlightFinder action.
2. Select a stepto parameterize.
toPort àclick valueà parameterize
3. Enter theparameter information
a.Select Data Table
b. Enter Name arrival
c. Select Global sheet(run on the test not onthe action)
d. Click OK
4. Parameterizeadditional steps. From_Month and To_Month
5. Enter data in Data Table
6.Save
File>Test Settings中Run标签控制GlobalSheet的执行,每个Action的CallProperties控制对应LocalSheet的执行