day 13 session 2 day 14 qtp-e0

Upload: govardhan-reddy

Post on 08-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    1/114

    CONFIDENTIAL

    Getting Started With

    QuickTest Professional

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    2/114

    13 July 2009

    Introduction

    Limited resources

    Tight Deadlines

    Reduce TCO Work flawlessly

    New technologies

    New Business

    Processes

    TESTING TOOLSQTP

    Win Runner

    Load Runner

    Silk Test

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    3/114

    13 July 2009

    No Testing Manual Testing4 Time consuming4 Low reliability4 Human resources4 Inconsistent

    Automated Testing4 Speed4 Repeatability4 Programming

    capabilities

    4 Coverage4 Reliability4 Reusability

    Why Use Testing Tools ?

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    4/114

    13 July 2009

    Fast: Automated tests run significantly faster than human users

    Reliable: Tests perform precisely the same operations each time theyare run, thereby eliminating human error

    Repeatable: You can test how the Web site or application reacts afterrepeated execution of the same operations

    Programmable: You can program sophisticated tests that bring outhidden information

    Comprehensive: You can build a suite of tests that covers everyfeature in your Web site or application

    Reusable: You can reuse tests on different versions of a Web site orapplication, even if the user interface changes

    Benefits of Automated Testing

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    5/114

    13 July 2009

    QuickTest Professional is a tool from the Mercury group forfunctional test and regression test automation

    What is QTP?

    Quick Test is a graphical interface record-playback automation tool.Its an easy to use tool compared to WinRunner. Users can createsophisticated test suites with minimal training

    Currently we have 9.1 version in the market with more featurescompared to previous stable release 8.2, 8.0

    Mercury allows a 14-day trial version so anyone can download and

    give a try

    The language used for constructing QTP is C++

    About QTP

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    6/114

    13 July 2009

    To start test scripts over a web application, you have to enable the

    Web add-in. You can create Web object checkpoints You can perform checks on Web page properties, text, and tables. You can also perform checks on objects within your application or

    Web site, such as images or form elements.

    You can also output property or text values from the objects in yourWeb site.

    You can use this feature to see if data is updated or a record is createdas a result of an operation performed.

    You can create a Microsoft Query using wizard or manually define anSQL statement.

    Recovery Manager Scenario wizard available in QTP helps you indefining the next operation to be performed when an error is

    encountered.

    Web Testing:

    DataBase Tests:

    Recovery Scenarios:

    Features available in QTP

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    7/114

    13 July 2009

    Scripting Language VB Scripting

    Environment Operating Systems: Windows XP, 2000, 98, NT, ME Web Technologies: HTML, DHTML, JavaScript Browsers: Internet Explorer, Netscape, AOL Emerging Technologies: .Net Winforms, Webforms, Web services,

    J2EE Web services, XML, WSDL, UDDI Terminal Emulators: 3270, 5250, VT100 Server Technologies:

    Oracle, Microsoft, IBM, BEA, ODBC, COM/COM+ Multimedia: RealAudio/RealVideo, Windows Media Player Languages: European, Japanese, Chinese (traditional and

    simplified), Korean applications (MFC), Visual Basic, Java, ActiveX

    Core Environments: Windows Enterprise Applications: SAP, Oracle,PeopleSoft, Siebel

    Features available in QTP

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    8/114

    13 July 2009

    QTP uses VBScript, WinRunner uses TSL (Test Script Language)

    QTP is advanced keyword driven, Winrunner is not

    Scripting can be avoided by expert view, by which Business

    analysts can also easily create test scripts with no programming

    code

    Object repository and scripting are in sync

    QTP supports session based recording

    QTP supports ".NET" application, Winrunner doesn't support

    QTP has "Active Screen" support which captures the application, not

    available in WR.

    QTP has "Data Table" to store script values, variables which WR does

    not have.

    Differences between QTP and WinRunner

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    9/114

    CONFIDENTIAL

    Glance at the Tool

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    10/114

    13 July 2009

    QTP Provides ActiveX,

    Visual Basic and WebAdd-ins by default.

    Other add-ins available onpurchase are: Java, DotNet, Oracle, PeopleSoft,SAP, Terminal Emulatoretc.

    Tip of the Day is alsoavailable

    Add-in is a repository oflist of standard classes

    Add-In Manager

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    11/114

    13 July 2009

    The startup screen contains

    shortcuts to: Tutorial on QTP Start Recording a New

    Script Open an Existing script

    Open a Blank script

    Tip of the Day is alsoavailable

    You can disable this screen

    by using the checkbox

    provided.

    Startup Screen

    C l Vi

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    12/114

    13 July 2009

    Toolbar: Three segments of toolbars are available andcan be selected from the View Menu

    Tree View: Gives the script in a TreefashionExpert View: Gives the script in the form ofstatements. Knowledge on VBScript will behelpful to understand this view

    Test Pane: Contains the QTP Scriptrecorded

    Test details pane: This screenholds the snapshot of the screen(Active Screens) when therecording is done. This helps ininserting checkpoints and inwalking through the scripts.

    Data Table: HoldsParameterized values.

    Debug Viewer: Usefulwhile debugging thescript

    Complete View

    C l Vi

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    13/114

    13 July 2009

    Complete View

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    14/114

    CONFIDENTIAL

    Create A Basic Test

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    15/114

    13 July 2009

    Create A basic Test

    Set initial conditions

    Record the business processSave the Test

    Run the Test

    View the results

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    16/114

    13 July 2009

    Set the Initial Conditions

    From the Sample applications open the Mercury Tours

    Web-site.Enter the website using following user name and password.

    Username: Training

    Password: mercury

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    17/114

    13 July 2009

    Record the Business Process In the QTP toolbar click on theRecord button. The Record and

    Run dialog box appears. In that select the Web tab.Now check the radio buttonsaying Open the followingbrowser when record or runsession begins.

    In Browser details mention theMicrosoft Internet Explorer inType andhttp://newtours.demoaut.com/ inAddress.

    Also check the checkboxes

    saying Do not record and run thebrowsers that are already openand Close the browser when thetest is over

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    18/114

    13 July 2009

    In the windows applications tabcheck the radio button saying

    Record and run these application(opened on the session start).

    This setting prevents you frominadvertently recording operationperformed e-performed on

    various Windows applications(such as email) during a recordingsession.

    Click OK.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    19/114

    13 July 2009

    Save the Test

    Save the test on Windows File System.

    QTP creates an entire structure of files and directories tosupport a single QuickTest script for each saved test.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    20/114

    13 July 2009

    Run the Test

    Use the Run button to begin playback from the top of the

    test.

    The Run from Step option in the Test menu is used to runthe test from a selected step to the end of the currentaction, if running from the Expert View, or to the end of thetest , if running from the Keyword View. Thus it enables us

    to check a specific part of the application or to confirm thata certain part of the test runs correctly.

    The Update Run option in the Test menu is used toupdate the Active screens, Checkpoints and the test

    object descriptions.

    Select the location of the test result-either a new resultsfolder or a temporary folder.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    21/114

    13 July 2009

    Viewing the Test Results

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    22/114

    13 July 2009

    Viewing the Test ResultsTest results can be stored in their own location (fordocumentation) or in a temporary location that is overwritten eachtime the test is run (debugging).

    QTP generates the result file for the test cases at the end of testin the form of XML tree. The result file provides detail regardingPASS and FAILS counts, error messages, and may providesupporting information that allows users to determine theunderlying cause of a failure. Frequently, however, users mayneed to re-execute the test case and observe the failure directly.

    The three status reviewed in the test result:

    1) Passes- Shows the count of the objects where the action issuccessful.

    2) Failed Shows the count of the objects where the actioncompletely failed.

    3) Warning- Shows the count of the objects where the actionis completed but not successfully.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    23/114

    13 July 2009

    Passed Object

    Partially passed object

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    24/114

    CONFIDENTIAL

    Working With Object

    Properties

    W ki With Obj t P ti

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    25/114

    13 July 2009

    Working With Object Properties

    Working with Object RepositoryUsing Object Spy

    Highlighting, Locating and Adding New Objects.

    W ki With Obj t R it

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    26/114

    13 July 2009

    Working With Object RepositoryObject repository displays a tree of all objects in the currentcomponent or in the current action or entire test (depending

    on the object repository mode you selected). We can viewor modify the test object description of any test object in therepository or to add new objects to the repository.

    There are two types of object repositories:

    Shared object repositoryPer action repository

    Record the test and save it.

    Now from QTP menu bar select Resources>Object

    Repository.You can rename the objects in the repository. For that right-click on the object and from menu select Rename. Afterrenaming is done click on OK and save the test.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    27/114

    13 July 2009

    Using the Object Spy

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    28/114

    13 July 2009

    Using the Object Spy

    Using the Object Spy, you can view the properties of anyobject in an open application. You use the Object Spy

    pointer to point to an object. The Object Spy displays theselected objects hierarchy tree and its properties and

    values in the Properties tab of the Object Spy dialog box.

    When the application is running, from the QTP toolbar click

    on the Object Spy button, Object Spy dialog box appears.In the dialog box, click on the pointing finger button, thecursor changes to pointing finger.

    Now using that click on the object in the application for

    which you want to the properties.Once this is done, a hierarchy tree of selected objects

    properties and values appears in the properties tab of thedialog box.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    29/114

    13 July 2009

    Highlighting Locating and Adding New Objects In Object

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    30/114

    13 July 2009

    Highlighting, Locating and Adding New Objects In ObjectRepositoryHighlighting an Object:

    In the Object Repository, select an object and the click on the

    Highlight in Application button.The select object will be highlighted in the Application.

    Locating the Object In the Object repository:

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    31/114

    13 July 2009

    Locating the Object In the Object repository:

    In the Object Repository, click on Locate in Repository button,

    the cursor changes to pointed finger. Once you click on the objectin the application, Select an Object dialog box appears. When

    you click OK, the object is highlighted in the Object Repository.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    32/114

    13 July 2009

    Adding new Objects to the Object Repository:

    In the Object Repository, select the Flight object. Now in the

    toolbar click the Define New Test Object button. The Define New

    Test Object dialog Box appears.From the Environment list, select Standard Windows, from the

    Class list, select WinButton, in the Name field type OK, in the

    Test Object Details section, click Value column for the Text

    property and type OK.

    Click Close to close the dialog box. A new object is added underthe Flight object. Close the repository and save the test and run.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    33/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    34/114

    CONFIDENTIAL

    Adding Synchronization

    Adding Synchronization

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    35/114

    13 July 2009

    Adding Synchronization

    Synchronization is a step added to a test that instructsQuickTest to wait for the state of a property on a particular

    object to change before proceeding to the next step in thetest.

    Just like a manual tester will wait for a visual cue to knowwhen the AUT has completed its processing, we instruct

    QTP to wait for a cue prior to moving on to the next step inthe test

    A synchronization point allows the test to pause while anapplication process completes, before moving on to the next

    step.

    To add a Synchronization point while recording a test from

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    36/114

    13 July 2009

    To add a Synchronization point, while recording a test, fromthe QTP menu bar select Insert > Synchronization Point,

    the cursor will change to pointing finger.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    37/114

    13 July 2009

    Once you select Object from the application forsynchronization, Object Selection: Synchronization Point

    dialog box appears. In that click OK.

    Now Add Synchronization Point dialog box appears. In thatset the Property name and Property value as the test

    requires and click OK.

    This will add a new step saying Wait Property in your test

    action. Thus, a synchronization point is added to the application.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    38/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    39/114

    CONFIDENTIAL

    Adding the Checkpoints

    What are Checkpoints?

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    40/114

    13 July 2009

    What are Checkpoints?A checkpoint verifies that expected information is displayedin a Application while the test is running. You can add eighttypes of checkpoints to your test for standard web objects

    using QTP.

    QuickTest will compare actual results from the test run withexpected results in our test plan.

    Expected results are based on what was recorded. Actual

    results are based on what occurred during playback/testrun.

    If the two values match, the checkpoint passes.

    A single checkpoint can verify one or more values.

    Checkpoints are used to:

    Verify the state of an object.

    Confirm that an application performs as expected.

    Type of Checkpoints

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    41/114

    13 July 2009

    Type of Checkpoints

    Bitmap Checkpoint: A check for a bitmap displayed say a logo thatneeds to be displayed for a user

    Standard Checkpoint: Use Standard checkpoint to verify state of objectslike a button enabled/disabled, checkbox selected or not.

    Text/Text Area Checkpoint: When a particular text display in a web pagehas to be verified. We can insert text checkpoint to verify the textdisplayed on a page or specifically between some text/fields

    Database Checkpoint: Can be used to check that database isappropriately updated when an activity is done on the application.

    XML Checkpoint: User can specify elements, attributes, and/or values tocheck. This checkpoint can be inserted over a XML displayed in thebrowser or over an XML file available in the system.

    Accessibility Checkpoint: The list of checkpoints that can be appliedover a page by default can be set using this option. A snapshot ofallowed list is provided.

    How to add Checkpoints

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    42/114

    13 July 2009

    How to add Checkpoints We can add checkpoint while recording the application or after

    recording using Active Screen.

    While recording an application, from the QTP menu bar select Insert> Checkpoint > select the checkpoint you want to apply.

    A Checkpoint Properties dialog box appears. Now select the

    properties for which you want the checkpoint to work from the list.

    Preferably text property is selected. Uncheck the remain checkbox of

    properties. Also check the condition either Before current step orAfter the current step as required by the application.

    A Operation saying check is added to the test action.

    The same steps are followed after recording, select the object from the

    Active screen right-click on it and from the menu option select the

    Insert Checkpoint and follow above steps.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    43/114

    13 July 2009

    Adding Regular Expressions

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    44/114

    13 July 2009

    Adding Regular Expressions While we add the checkpoint for the object in theapplication, we can set its text property value as a result ofregular expression.

    To do that in the Checkpoint Properties dialog box, checkthe text property and uncheck all the other properties. In

    the Configure Value pane ensure that Constant is check.

    Now click the Constant Value option button, a Constant

    Value Option dialog box appears.In the Value textbox enter the required regular expression

    e.g. [0-9]+, check the Regular Expression checkbox. Amessage box will pop up, click ok. Now on the dialog box

    also click ok.The object will not have the text value as the result of theregular expression.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    45/114

    13 July 2009

    S R l E i

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    46/114

    13 July 2009

    Some Regular Expressions-Expression Char Description

    Period . Matches any single character

    Asterisk * Matches zero to any number ofoccurrences of the preceding character

    Plus + Matches one to any number ofoccurrences of the preceding character

    Brackets [A-Z][a-z] Matches a range of characters

    [0-9] Matches a range of numbers

    \w Matches any alphanumeric characterincluding underscore

    \W Matches any non-alphanumericcharacter

    Digit \d Matches any digit

    \d{4} Matches exactly four digits

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    47/114

    CONFIDENTIAL

    Using Parameter

    Parameteri ation

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    48/114

    13 July 2009

    Parameterization

    Parameters allow for extensive reusability of an action or a

    test. Do the work once and use it many times. Note: A parameter is a placeholder for a value that will be

    passed to the test during the test run.

    Enhance your test to become data-driven.

    Describe and use multiple parameter types. Drive data in multiple iterations.

    Analyze errors during test execution.

    Parameterize a checkpoint.

    Adding Parameters- Create an Output

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    49/114

    13 July 2009

    dd g a a ete s C eate a OutputParameter

    Record the test for the Flight Reservation Application for inserting a neworder and faxing the order.

    Add synchronization point on the Insert Done progress bar and add

    standard checkpoint on the Fax Order No. window title bar and its value

    is a regular expression (Fax Order No. .*).

    In the Keyword view , select the Insert Done step and from the Active

    screen, right click on the Order No. field and select Insert Output Value.

    In the Object Selection- Object Value Properties dialog box opens, clickOK. The Output Value Properties dialog box appears, check the Text

    checkbox.

    Select the After Current Step option. Click OK. Ensure that a column

    Order_No_Text_Out appears in the Data Table.Save the Test.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    50/114

    13 July 2009

    Adding Parameters Parameterize to Accept

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    51/114

    13 July 2009

    Adding Parameters Parameterize to Acceptthe Input Value

    In the Keyword view, under the first occurrence of the Flight

    Reservation select Name step. Click the Value column and then clickthe Configure The Value button.

    The Value Configuration Options dialog box appears. Select the

    Parameter option. In the Name field, replace the existing value by

    Name.

    Ensure that the Global Sheet option is selected. Click OK. In the QTP Window, in the Data Table, in the Name column, type

    Sam, Laurence, Catherine in three rows.

    Save the test.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    52/114

    13 July 2009

    Using a Random Number Parameter

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    53/114

    13 July 2009

    Using a Random Number Parameter In the Keyword view, select the Tickets step. Select the Tickets step

    where the operation is Set. In the Value column click the Configure

    the Value button.

    The Value Configuration Options dialog box appears. In the dialog

    box, change the parameter type from Data Table to Random Number.

    Change the Numeric range from 0 to 100 to 1 to 10.

    Check the Name checkbox and in the Name field, type Tickets_Out.

    Ensure that the For Each Action Iteration option is selected.Click OK. Save the Test and Run.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    54/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    55/114

    CONFIDENTIAL

    Building Multiple and Reusable

    Actions

    Benefits of Test Modularity

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    56/114

    13 July 2009

    Benefits of Test Modularity

    Makes code reusable.

    Scripts are easy to maintain.

    Scripts are efficient.

    Saves development time.

    Building Reusable Actions

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    57/114

    13 July 2009

    Building Reusable Actions

    There are two types of Reusable Actions:

    Reusable: Action can be used in the local test, multiple times.

    External: These are reusable actions created in another test.This can be of two types. If a call to an external action is usedthe action is read only in the calling test. But, any existing actioncan be inserted as a copy of the original action. In this case, we

    can modify this copy of the external action in the calling test.

    Record a test and run it to verify that it passes.

    Now right-click on Action1 step and select ActionProperties from the menu.

    Rename the Action if you want and check the checkbox

    saying Reusable Action. Click OK in the HINT dialog boxand save the test.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    58/114

    13 July 2009

    Inserting Multiple Actions

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    59/114

    13 July 2009

    Now there are 2 ways of inserting the Multiple Actions: Inserting Copy of an Action

    When you insert a copy of an action into a test, the action iscopied in its entirety, including checkpoints, parameterization,and the corresponding action tab in the Data Table. The actionis inserted into the test as an independent, non-reusable action

    Once the action is copied into your test, you can add to, deletefrom, or modify the action just as you would with any otherrecorded action. Any changes you make to this action after youinsert it affect only this action, and changes you make to the

    original action do not affect the inserted action. You can insertcopies of both reusable and non-reusable actions. Inserting Call to an Action

    You can insert a call (link) to a reusable action that resides inyour current test (local action), or in any other test (externalaction).

    When you insert a call to an external action, the action isinserted in read-only format. You can view the components ofthe action in the action tree, but you cannot modify them.

    g p

    Steps to Insert a copy of an Action:

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    60/114

    13 July 2009

    Choose Insert > Copy of Action, right-click the action and selectInsert Copy of Action, or right-click any step and select Action >Insert Copy. The Insert Copy of Action dialog box opens.

    Type a meaningful name for the action in the New action namebox and give action description

    Specify where to insert the action : At the end of the test or Afterthe current step.

    Click OK. The action is inserted into the test as an independent,non reusable action.

    Steps to insert call to an Action: Choose Insert > Call to Action, right-click the action and select

    Insert Call to Action, or right click any step and select Action >Insert Call. The Insert Call to Action dialog box opens.

    In the Select an action box, select the action you want to insert

    from the list. Specify where to insert the action : At the end of the test or After

    the current step.

    Click OK. The action is inserted into the test as a call to theoriginal action

    Insert Call to Copy of Action

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    61/114

    13 July 2009

    py

    Insert Call to Existing Action

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    62/114

    13 July 2009

    Insert Call to Existing Action

    Using Local And Global Data Sheets

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    63/114

    13 July 2009

    Using Local And Global Data Sheets

    There are two types of sheets in any QTP, they are:

    Global sheetLocal sheet

    Global sheet: Global sheet is unique. Global sheet is used inorder to store values in the sheet and the values stored inGlobal sheet can be used in all the actions.

    Local sheet: Each and every action in the script will have itsown Local sheet, name of the Local sheet of a particular actionis same as the action name.

    You can also import and export external excel sheets.

    Two Different Actions referring the same Global data sheet.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    64/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    65/114

    13 July 2009

    Two Different Actions referring their individual Local data sheets

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    66/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    67/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    68/114

    CONFIDENTIAL

    Adding Steps Without

    Recording

    Addi St ith t R di

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    69/114

    13 July 2009

    Adding Steps without Recording

    We can add steps to the Test without recording the

    application.Following steps help us to know how to add steps withoutrecording taking the example of Login Window of FlightReservation System:

    Operate on Login window

    Add Objects to Object RepositoryVerify that Login Window exists. Insert a Report StepSet the Else Statement (Using Step Generator)

    Operate on Login window

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    70/114

    13 July 2009

    Operate on Login window

    From the QTP menu bar, select Insert menu and in that

    select Conditional Statement. Select IFTHENstatement which added to Keyword view.

    In Keyword view, in Item column select Statement step,

    it changes to list. Select Object from Repository. The

    Select Object For Step dialog box appears. Leave thatopen.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    71/114

    13 July 2009

    Add Objects to Object Repository

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    72/114

    13 July 2009

    Open the Login Window of Flight Reservation application.

    In the Select Object for Step dialog box, click the pointing

    finger button.Using the pointing finger cursor click on the Login window.The Object selection dialog box appears. Click OK. This

    adds Login object to the Repository tree in Select Object

    for Step dialog box.Repeat the above step for AGENT NAME, PASSWORDand OK button.

    Verify that all objects added appear in the object repository

    tree in the Select Object for Step dialog box.In the Object Repository tree, select Login Window objectand click OK. The object will be added to the IF statementin Keyword view.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    73/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    74/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    75/114

    13 July 2009

    Verify That Login Window Exists

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    76/114

    13 July 2009

    In Keyword View, select Login Object. In the Operatecolumn, change the operation from ACTIVE to EXIST.

    From QTP menu bar select Insert and from there selectNew Step to add new step.

    From the list select Agent Name and in its Value columntype your First name.

    Repeat the above two steps for Password and entermercury as value.

    From QTP menu bar again select Insert and from thereselect New Step to add new step.

    From the list select OK button to add it.

    Save the test and run it. The test passes.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    77/114

    13 July 2009

    Insert a Report Step

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    78/114

    13 July 2009

    In Keyword view, select OK step.

    From QTP menu bar, select Insert and in it select

    Report. The Insert Report dialog box appears.In this dialog box, from status list select Passed.

    In the Name field, type Login Window Found.

    In the Details field type The Flight Reservation

    Application Login Is Successful. Click OK and close theFlight Reservation System application and open it againbut do not login.

    Save the Test and Run.

    View the test results and see how Reporter Event reports

    the test status.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    79/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    80/114

    13 July 2009

    Report in the Test Results:

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    81/114

    13 July 2009

    Set the Else Statement (Using Step Generator)W i i hi h L i i d i t f d

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    82/114

    13 July 2009

    We are preparing a case in which Login window is not foundusing the Else statement.

    In the Keyword View, select the If statement. From the QTP

    toolbar select Insert > Conditional Statement > Else. The Elsestatement appears at the end of the test. Click the Else statement,

    the step changes to list.

    Select the Step Generator. The Step Generator dialog box

    appears.

    From the Category list, select UtilityObjects. From the Object list,

    select SystemUtil. From the Operation list, select Run.

    In the Argument section, select the File row. In the Value

    column, type the absolute path of the Flight Reservation

    application: C:\Program Files\Mercury Interactive\QuickTestProfessional\Samples\Flight\App\Flight4A.exe and click OK.

    From the QTP toolbar, select Insert > New Step, a new step is

    added. From the list, select Object Repository. The Select Object

    For Step dialog box appears.

    From the object repository tree, select Login window object and

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    83/114

    13 July 2009

    j p y , g j

    click OK.

    Follow same steps for Agent Name and Password and their

    respect value columns type Training and mercury.

    Also add the OK step by following the same steps. Ensure that

    these steps are added as the steps in the Login window.

    Close the Dialog box and save the test. Run the test and view theresults. Verify that the Else statement is executed.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    84/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    85/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    86/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    87/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    88/114

    13 July 2009

    The Else Statement is executed here.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    89/114

    CONFIDENTIAL

    Creating A Custom

    Checkpoint

    Creating A Custom Checkpoint Record the test for inserting new order From the Keyword View select

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    90/114

    13 July 2009

    Record the test for inserting new order. From the Keyword View, selectthe Tickets step that has the Set in the Operation Column.

    To create an output step for the no. of flight tickets, in the Active Screen,

    right click the Tickets field highlighted. Select the Insert Output Value.The The Object Selection- Output Value Properties dialog box appears.Click OK. The Output Value Properties dialog box appears.

    Check the Text checkbox and click Modify. The Output Option dialog

    box appears. In the Name field type NTickets. Click OK to close the

    Output Option dialog box. Select After Current Step option. Click OK to close the Output Value

    Properties dialog box.

    Verify that:

    A Tickets step appears in Keyword View that has the Output value in the

    Operation column. A Column named Ntickets appears in the Global sheet of Data Table.

    Follow the above steps for Price and Total fields in the Active screen

    and create output parameter name NPrice and NTotal respectively.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    91/114

    13 July 2009

    Now in the Data Table, double-click the fourth column without a name, theChange Parameter Name dialog box appears. In the Data Column Name

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    92/114

    13 July 2009

    g g pp

    Field, type PriceChk. Click OK. The new column appears in the Data

    Table. Add the values to the NTickets, NPrice, & NTotal column as 1, 123

    , 123 respectively. In the first row of the PriceChk column type the formula

    =round(a1*b1,2)=round(c1,2)

    To perform the calculation press Enter. The True value appears in the

    PriceChk column. And if you change the NTickets value to 2, the False

    value appears in the PriceChk Column.

    Now in the Keyword view, select the Total step that has Output value in

    the Operation column. From the QTP menu bar, select INSERT > STEP

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    93/114

    13 July 2009

    p ,

    GENERATOR. The Step Generator dialog box appears.

    In the Category List, select Utility Objects. In the Object list, select Data

    Table. In the Operation list, ensure that the Value is selected. For the

    ParameterId field, click in the Value column and type PriceChk.

    Ensure that the Return Value checkbox is checked. In the Return Value

    field, type vPriceChk. Click OK to insert this step into test.

    From QTP menu bar, select Insert > Conditional Statement > IfThen

    Click the Value cell of this step and overwrite True with vPriceChk=True . Insert a Report to check the status of this step.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    94/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    95/114

    CONFIDENTIAL

    Adding A Database

    Checkpoint

    Adding a Database Checkpoint Record a new test for inserting an order and add synchronization andcustom checkpoint as discussed before for the Order No field and Tickets

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    96/114

    13 July 2009

    custom checkpoint as discussed before for the Order No. field and Ticketsfield and name the checkpoint as GUIOrder_No. and NTickets respectively.

    Now from the Keyword view, select the Tickets step that has Output value

    in the Operation column. From the QTP menu bar, select Insert >Checkpoint > Database Checkpoint. The Database Query wizard opens.

    In the Query Definition section, ensure that the Create Query UsingMicrosoft Query is selected. Check the Maximum No. Of Rows checkbox.Set it to 5. Ensure that Show Me How to Use Microsoft Query checkbox ischecked. Click Next. In the Instruction for Microsoft Query dialog box, click

    OK. In Choose the Data Source select QT_Flight32*. Ensure that Use theQuery Wizard checkbox is checked. In the Query Wizard- Choose Columnsdialog box, in the Available Tables and Columns list, double-click theOrders table to display all columns. Select Order_Number,Tickets_Ordered and Agents_Name columns and use right arrow button toadd. Click Next. Again Click Next. Then for sort order use Order_Number.Also select Ascending. Click Next. And then click Save Query. Ensure thatthe Exit and Return To QTP option is selected.

    Click Finish.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    97/114

    13 July 2009

    Continue

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    98/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    99/114

    CONFIDENTIAL

    Creating test on Web Application

    Creating Test on Web Application

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    100/114

    13 July 2009

    Enabling the Web Add-in

    Specifying the Record and Run Settings

    Working with Web Objects

    Specifying Time Out for a Web Page

    Inserting Standard and Test Checkpoint in a WebPage

    Using Parameters

    Enabling The Web Add-in

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    101/114

    13 July 2009

    Open the QuickTest Professional and in its Add-in Manager selectWeb add-in.

    Or you can also do this. Select blank test. From the File menu selectSettings > Test Setting properties > click Modify

    A Modify Associated Add-in dialog box appears. Select Web add-inand click OK.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    102/114

    13 July 2009

    Specifying the Record and Run Settings

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    103/114

    13 July 2009

    From QTP menu bar, click on Record. A Record and Run Settings

    dialog box appears. In that, in Web tab, click the radio button saying record and run teston any open browser. Click OK.

    Note: As a best practice, before you start recording on a browser, closeother browsers and applications and set the record and run settings.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    104/114

    13 July 2009

    Working with Web Objects

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    105/114

    13 July 2009

    A Web application uses Web classes and Web objects whereas a Windows-based application uses windows object classes and objects. In addition,

    A Web application uses a greater variety of objects as compared to aWindows-based application. Some examples of Web objects are hyperlinks,images, and frames.

    From the QuickTest Professional menu bar, select RESOURCES OBJECTREPOSITORY to identify the Web objects used in a Web application.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    106/114

    13 July 2009

    Specifying Time Out For a Web Page From QTP menu bar, select File > Settings.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    107/114

    13 July 2009

    A Test Settings dialog box appears. In the Web tab, in the text box namingBrowser navigation timeout: set the required timeout for the webpage. ClickOK.

    Inserting Standard and Text Checkpoint

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    108/114

    13 July 2009

    Record a test on Web Application Mercury Tours Web site.

    In the Keyword View, select the passCount step that as 4 value in

    the value column.From the QTP menu bar select Insert > Checkpoint > Standard

    Checkpoint. The Checkpoint Properties dialog box appears.

    In that, check All Items checkbox and uncheck the remaining

    checkboxes.

    Also select the After Current Step option. Click OK. In Keyword view again, select the Flight Confirmation: Mercury step.

    In Active Screen, highlight the Your Itinerary Has Been Booked! text

    and right-click on the text.

    Select Insert Text Checkpoint. The Text Checkpoint Properties

    dialog box appears.

    Ensure that the Before Current Step option is selected. Click ok.

    Run the test and view the results.

    Inserting Standard Checkpoint

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    109/114

    13 July 2009

    Inserting a Text Checkpoint

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    110/114

    13 July 2009

    Using Parameters In the Keyword view, click the Value property of the FromPort step. The

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    111/114

    13 July 2009

    In the Keyword view, click the Value property ofthe FromPort step. TheConfigure the value dialog box appears. Click the Configure thevalue button.

    In the Value Configure Option dialog box, select Parameter option.In the Name field type fromCity. Click OK.

    Repeat the above two steps for the ToPort step and name theparameter as toCity.

    In the respect column of data table enter the values for fromCity andtoCity that are found in the list in application.

    Save the test and run. View the test results and the test should pass.

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    112/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    113/114

    13 July 2009

  • 8/7/2019 Day 13 Session 2 Day 14 QTP-E0

    114/114