qtp session_ testing tools automation

Upload: kbpvarma

Post on 09-Apr-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 QTP Session_ Testing Tools Automation

    1/71

    Types of Automated Tools:3types:

    1) Functional Tool -> EX: Quick Test Professional(QTP) -> Win Runner2)Management Tool-> EX: Test Director-.>Quality Center3) Performance Tool-> EX: Load Runner

    QTP:Type of the Tool: FunctionalCompany: Mercury interactive incorporation (HP)Developed by Mercury

    Scripting Language: VBVersions: 1st. VER. 5.5 released in 2002Version: 2nd VER. 6.5, 7.6, 8.0,Version 5th 8.2 released in 2005Version 6th 9.0 released in 2006

    Version 7th

    and 8th

    9.1 and 9.2 released in 2007Operation systems those are compatible withQTPWin 2000 serverAdvanced 2000 server

  • 8/8/2019 QTP Session_ Testing Tools Automation

    2/71

    Win 2000 ProWin 2003 Server2003 advanced server

    VER 9.2 is compatible with XP Pro.

    QTP is not compatible with UNIX and Linuxplatforms

    -INTRODUCTION COMPLETE-

    The Anatomy of the QTP

    Add in Manager:It is a feature provided by QTP which is usedfor specifying the environments before you are

    entering into the QTP so that, it makes the QTPcompatible with that environment. By defaultQTP provides, ActiveX, VB, and Webapplications.Apart from this, QTP is always compatible with

    standard windows environment.

    QTP screen is divided into 7parts

    1)Test Pane

  • 8/8/2019 QTP Session_ Testing Tools Automation

    3/71

    It is an area provided by QTP used forviewing the test script. It also allows theuser to do any kind of modifications on the

    test script. It represents the script in 2views.

    A. Expert View:It represents the script using VB script

    language

    B. Keyword view:It represents the script using GUI(Graphical Users Interface) which is further

    divided into 4 parts.1) Item, 2) operation 3) value 4)documentation

    2) Active screen:It is feature provided by QTP which showsthe application state for each and everyscript statement in terms of screen shotswhich is used for the following. 1) To

  • 8/8/2019 QTP Session_ Testing Tools Automation

    4/71

    understand the script easily 2) to enhancethe script easily

    3) Data Table:It is also called Formula-One-Sheet which isdeveloped by the third party and integratedby the QTP. It is used for the following:1) Used for holding the test data

    2) It has a capacity of importing the testdata from different data sources like excelsheet, flat files and database.3) It isolates the test script from the datasource.

    4) It provides an API (Application programinterface) to interact with it directly5) QTP maintains two copies of data tables1) Design time data table2) Run time datatable.

    (Compares both tables to determine if thetest result is pass or fail)

    4) Debug Viewer Pane:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    5/71

    It is used for viewing, modifying or settingthe current values of variables during theexecution break. Using the 3 tabs by names,

    Watch expressions, Variables andcommand

    5)Information View:It is in the form of GUI and contains 4 tabs

    Details: Describes of the each and every lineof test pane areaItem, Action, Line6)Missing Resources pane: Click on View in

    the Information View and select Missing

    Resources.It is also in the form of GUI. It contains 2 tabs.Item and Details.Item contains missing item in the script.

    Details describe the properties of that item.

    7)Tool Options:All the available options are tool options.View-> Information view:What ever is given in the script area is givenhere. (9.2)

  • 8/8/2019 QTP Session_ Testing Tools Automation

    6/71

    Recording and running feature in QTP

    Record and run settings is the featureprovided by QTP which has to becompulsorily used by a test engineer at leastfor every new test before recording andrunning in order to make the QTP aware

    about on which application is going toperform operations like record and runsession. For doing the same QTP provided 2options.

    1) Record and run on any open windows based

    application

    2) Record and run test on these applications

    (opened on session starts)

    Navigation for recording and testing:Activate the menu item test Automation

  • 8/8/2019 QTP Session_ Testing Tools Automation

    7/71

    Select the option recordSelect one of the following options

    1) record and run test on any open windows

    based application2) record and run test on these

    applications ( opened on sessions start)

    9.2 Record and run has more optionsunder record and run settings:Application opened by Quick TestApplications opened via desk topApplications specified below (browse the

    desired location)If at all the second option (3rd option in 9.2under second option) is selected, click on theadd button, click on browse and browse thedesired application and select the applicationand click on open. Click on OK, Click on applyand click OK.

  • 8/8/2019 QTP Session_ Testing Tools Automation

    8/71

    If you want to work with a specifiedapplication then select the 2nd option in therecord and run settings.

    If you want QTP to record only thespecified application then select the firstand third options.

    Operational overview of Recording

    feature in QTP:

    While recording QTP will do thefollowing:

    1) all the user actions are converted

    into script statements

    2) The corresponding object

    information is stored in objectrepository

    And

  • 8/8/2019 QTP Session_ Testing Tools Automation

    9/71

    Operational overview of Running

    feature in QTP:

    While running QTP will do the following:

    1) first of all QTP will try to understandthe script statement i.e. what actionto be performed

    2) Once it realizes what action to be

    performed on an object, it needs toidentify the object.

    3) For identifying the object it needssome information. For that

    information it will go to objectrepository and search for theinformation.

    4) Once it identifies the information,

    using that information it tries toidentify the object.5) Once the object is identified, it

    performs the action on it.

  • 8/8/2019 QTP Session_ Testing Tools Automation

    10/71

    Types of Recording Modes:

    Normal or Context Sensitive orStandard Recording mode

    Analog Recording mode Low Level Recording mode

    1) Normal or Context sensitive or standardrecording mode:

    It is used for recording the actionsthat are performed on the standardGUI objects

    2)

    Analog recording mode:When ever the context sensitiverecording fails, or whenever the userwants to perform continuous recording

  • 8/8/2019 QTP Session_ Testing Tools Automation

    11/71

    then there is a special recording modeprovided QTP is known as Analogrecording mode.

    NAVIGATION for Analog recordingmode:Keep the tool under the normal

    recording mode Activate the menu item

    Automation,select the option Analog

    Recording, Select one of the following options:

    a) Record relative to the screenb) Record relative to the

    following window.If the second option is selected specifythe window title of the application using

  • 8/8/2019 QTP Session_ Testing Tools Automation

    12/71

    the hand icon and click on start Analogrecording.

    3) Low level recording mode:When ever there is an unsupportedenvironment by the QTP, but still theuser wants to record at least minimum

    number of operations on the applicationthen the special recording modeprovided by QTP is known as low levelrecording.

    Note: If the user wants to be underanalog or low level recording mode,

    first of all he should be under Normal

    recording mode.************************************************

  • 8/8/2019 QTP Session_ Testing Tools Automation

    13/71

    OBJECT REPOSITORY:

    It is a storage place where one can storethe objects information and also acts asinterface between the test script and theAUTor Application Under Test in orderto identify during execution.

    .mtr (module test repository) is the

    extension for saving the per action

    repository files.

    .tsr (test shared repository) is the

    extension for saving the Shared

    Repository files

    TWO Types of Object Repositories:

    a. Per Action Repository:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    14/71

    Per each and every action in a test QTPwill separately create a repository andmaintains that repository.

    b. Shared Repository:It is a common place where one canstore the objects information and canbe associated to multiple testsAdvantage: easy to maintain.Disadvantage: Comparatively takesmore time during execution

    NAVIGATION FOR CREATING ASHARED REPOSITORY:

    1) Open the application

    2)Activate the menu item resources

    3)Select the option Object repository

    4)Click on Add objects local button

    5)Click on the title bar of the

    application you require to share info

    about

  • 8/8/2019 QTP Session_ Testing Tools Automation

    15/71

    6)Click on OK

    7)Select the third option(select all

    objects)

    8)Click on OK9)Click on Export button

    10)Browse the desired location

    11)Specify the desired file name with .tsr

    extension or test shared repository

    12)Click on Save

    Navigation for Associating the sharedthe Repository:

    Navigation:Go to Resources and Associate

    Repository

    Click on + sign

    Select the desired .tsr file

    Click on Add >

    Click on Repository View to confirm

  • 8/8/2019 QTP Session_ Testing Tools Automation

    16/71

    Operations on Object Repository:

    One can perform the following operations onthe Object Repository:

    a) Adding the ObjectsNavigation:

    Open the application,Resources -> object repository->ObjectClick on add object button locally->click on the title bar of the desiredapplication->click OK

    ->select one of the following options:Click on OK

    b)Navigation for deleting the objects:Select the desired object in the Objecthierarchy right click on that select optiondelete, and confirm by clicking on yes.

    c) Navigation for renaming:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    17/71

    Follow the above instead of delete selectrename and rename

    d)Navigation for updating the list ofproperties:

    Select the object in the object hierarchy,click on add/remove button,Select the desired properties to be addedor deselect to remove.Click on OK

    For 9.2 High light button is in View -> highlight the abjectLocate Object is useful for finding out thespecified object in the Repository.Export button is existing in the fileIf you want to change the properties

    value, click on constant value button and

    specify the desired value, click on OK

    Merging Of the Repositories:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    18/71

    Resources->object repository manager-

    >tools->Object repository merge to-

    >browse the primary file->browse the

    secondary file you want to merge->clickOK

    To save them click on Save and specify

    the file name you want it to save as.

    OBJECT IDENTIFICATION:

    It is based on the following properties:

    1)Mandatory Properties:2) Assistive Properties:3) Base Filter Properties:4) Optional Filter Properties:5) Ordinal Identifier:

    QTP learns the information in the following way:At first QTP learns the complete list:1) Mandatory properties:Analyzes it selfwhether these properties are sufficient for

  • 8/8/2019 QTP Session_ Testing Tools Automation

    19/71

    identifying the object uniquely. If it feelsinsufficient then it will learn the first

    2) Assistive property: If it still feelsinsufficient, then it will learn the next assistiveproperty. This process continues till the lastavailable assistive property or till the QTP issatisfied. If it still feels insufficient then it will

    learn the Ordinal Identifier.Note: If smart identification mechanism isinvoked, then along with the mandatoryproperties, QTP learn the 3) base filter and 4)

    optional filter properties and stores themseparately. The remaining process is same asabove.

    Note:

    The Mandatory properties, Assistive propertiesand the ordinal identifier that was learnt arestored in the object repository.

  • 8/8/2019 QTP Session_ Testing Tools Automation

    20/71

    5) ORDINAL IDENTIFIER:

    There are 3 types of Ordinal Identifiers.a.Location:

    Based on the sequence in which the objectsare located in

    AUT (Application under Test) QTP willgenerate the numbers starting from 0 zeroon wards.

    b. Index:Based on the sequence of the programs, QTP

    will generate the numbersStarting from 0 on wards

    c.Creation Time:Based on the loading time of the WEB pageQTP will generate a sequence of numbers

    starting from 0 (Zero) on wards.

    Navigation:Tools->object Identification->select thedesired environment->select the desired

  • 8/8/2019 QTP Session_ Testing Tools Automation

    21/71

    object class to be configured EX: VB buttonsetc.

    Click on Add/remove button->select thedesired properties to be addedFor mandatory and assistive properties

    Select the check box enable smart

    identification click on configure buttonSpecify the base filter and optional filterproperties by clicking on the correspondingadd/remove button. Click OKSelect the desired ordinal identifier. Click ok

    Note: this configuration will be in effectfrom the next new file onwards.

    OBJECT SPY:

    It is a handy feature provided by QTP, whichshows the complete information like list ofproperties, list of methods, syntax for

  • 8/8/2019 QTP Session_ Testing Tools Automation

    22/71

    methods and description of methods for bothTest objects as well as Runtime objects.

    Runtime Objects:The original objects present in the applicationare known as Runtime objectsTest Objects:Test objects are the references for the runtime

    objects created by QTP, used by QTP duringexecution in order to identify the runtimeobjects.

    QTP LIFE CYCLE:

    1) Test Planning2) Generating the basic Test3) Enhancing the test4) Debugging the test

    5) Executing the test6) Result analysis

    1) Test planning:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    23/71

    In the test planning phase, the test lead willidentify the areas to be automated and theautomation test engineer will do the

    following:A. Understanding the requirementsB. Analyzing the flowsC. Pre configuration settings to the tool in

    order to make the tool ready for further

    operations

    2) Generating the basic test:In the phase automation test engineer willgenerates the basic test for both positive

    and negative flows

    3) Enhancing the test:1) CHECK POINTS:2)Synchronizing the test:

    3) Parameterize the test or data driventesting (DDT):

    4) Inserting the output values:5) Measuring transactions:6) Inserting the programmatic statements

  • 8/8/2019 QTP Session_ Testing Tools Automation

    24/71

    7)Inserting the script statements manually

    A. CHECK POINTS:

    It is also called as validation point ortestpoint which checks the application stateor data state during the execution at anypoint of time.

    Operational over view of Check Point:It is divided into 2 phases.Pre execution phasea) Captures the expected valueb) Generates the test script statement

    While execution phasea) Captures the actual valueb) Compares the actual value with the

    expected value

    c) Displays the result

    Types of Check Points:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    25/71

    I. StandardII. Bitmap

    III. TextIV. Text AreaV. Database

    VI. XMLVII. Accessibility

    VIII. PageIX. TableX. Image

  • 8/8/2019 QTP Session_ Testing Tools Automation

    26/71

    Checkpoint

    Type

    Description Example of Use

    Standard

    Checkpoint

    Checks values of an object's

    properties.

    Check that a radio button is selected.

    ImageCheckpoint

    Checks the property values of animage.

    Check that the image source file is correct.

    Table

    Checkpoint

    Checks information in a table. Check that the value in a table cell is correct.

    Page Checkpoint Checks the characteristics of a Web

    page.

    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 a Web

    page or application.

    Check whether the expected text string is displayed in

    the expected location in a test object.

    Text AreaCheckpoint

    Checks that a text string is displayedwithin a defined area in a Windows-

    based application.

    Check that an area of a dialog box includes text thatwas entered in another part of the application.

    Bitmap

    Checkpoint

    Checks an area of a Web page or

    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 ContentAccessibility 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 Web page.

    1)Standard check point:

    It is used for checking the standard GUIobjects propertys value.Navigation:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    27/71

    Open the desired application that youneed to testKeep the tool under recording mode

    Activate the menu item insertSelect the option check pointSelect Standard Check pointTake the hand iconClick on the desired object or application

    that you want to testClick OKSelect the desired properties to becheckedClick OK

    Stop recordingClick on RUN and analyze the results

    2) Bit map check point:It is used for checking the bit maps or

    comparing the bitmapsNavigation: Same as above but canselect the desired area of the bitmap

    3) Text check point:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    28/71

    Navigation:4) Text area check point:

    5) Database check point:

    Database Check Point is used for checkingthe contents of the data table in aDatabase.

    Navigation Database Check Point:

    Insert -> check point-> databasecheckpointSelect the specify SQL statement

    manuallyClick nextCreate->new->Select the desired driverNext

    Specify the data source nameNextFinishSelectSelect the desired drive

  • 8/8/2019 QTP Session_ Testing Tools Automation

    29/71

    Select the desired databaseOkOk

    OkSpecify the SQL statement manually> Select *from Data driver->Select the constant value to be

    parameterizedClick on Parameterize buttonSelect step by step parameterization,Next->Click on Parameter options button

    Specify the desired column nameClick on OKClick on Finish and click OK

    Navigation:

    2) Through Keyword View:Select Keyword ViewSelect the constant value to beparameterizedClick on configure the value button

    Select the option parameterSp the desired column name or specify thenameClick on OK

  • 8/8/2019 QTP Session_ Testing Tools Automation

    37/71

    3) Manual Parameterization:In order to avoid the above navigation, onecan manually insert the following

    statements:Syntax:Vbwindow (form1).vbedit (val1).setdatatable (V1, 1)Vbwindow (form1).vbedit (val2).set

    datatable (V2, 1)Vbwindow (form1).vbButton (ADD).ClickNavigation for importing the data fromData base/flat files/xls:Right click in the data table

    Select fileSelect import from fileOKBrowse the location of the desired fileSelect the desired file

    Click on OPENNote:In order to have the Test Results in theRun Time DATA TABLE we need to set theCheck Point

  • 8/8/2019 QTP Session_ Testing Tools Automation

    38/71

    Navigation to Parameterize the CheckPoint:

    Right click on the check point statement,Select check point propertiesSelect the desired propertiesparameterizedSelect the parameter option

    Click on the parameter options buttonSelect the desired column nameOK and OK

    E. Inserting the output values:

    It is a feature provided by QTP to capturea value from an application or Database orXML file and stores it under a specifiedcolumn in the runtime DATA TABLE duringexecution.

    F. Inserting the programmatic statements:Test Pane may contain 5 types of Programmatic

    statements:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    39/71

    2) Normal steps or Object calls3) Conditional statements4) Looping statements5) Comments(by using the word REM before the

    statement)6) Utility statements7) Reporter Statements:Reporter utility object is used for reporting a UserDefined MessageUDM to the results window

    Syntax for the Reporter StatementReporter.reportevent status,myreport,user

    defined message.

    Reporter.reportevent micdon,Myreport,I am the

    Best

    Adding comments:Comments can be inserted into the Test Pane areajust by preceding with an apostrophe OR USE AWORD REM FOR ADDING COMMENTS

    G. Inserting the script statements manually:

    EX: manual parameterization.

    4) Debugging the test:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    40/71

    It is a process of executing the program with sometemporary breaks in order to identify the errors to do thesame QTP has provided 3 step commands and a Break Point.

    a) Step into: it is used for executing a single step. If that

    step is a Function call or Action Call then it will enterinto a Function/Action.

    b)Step out: It is used for executing all the programmaticstatements from the pointer (arrow) and steps out ofthe Function/Action.

    c) Step over: It is used for executing the complete block

    of statements in a Function/Action if that step is aFunction Call /Action Call. Otherwise, it will executesingle step only.

    d)Break Point: It is a feature provided by QTP that isused for breaking the execution temporarily.

    5) Executing the test:

    A Test Engineer will execute the script in this Phase.

    6) Result analysis:

    A Test Engineer will analyze the results in this phase.

    Recovery Scenario:

    It is defined as a problematic situation wherein QTP needsto recover by itself.

  • 8/8/2019 QTP Session_ Testing Tools Automation

    41/71

    To do the same a Test Engineer would have already defineda solution and associated it to the test before theexecution starts.

    During the execution if QTP faces a problematic situationthen, if the solution is available it will use the solution andover comes that situation.

    There are 4 types of Trigger Events to over comedifferent kind of situations.

    a) Popup Window:This is used for defining a solution to over come aproblematic situation related to POP UP WINDOW.Navigation: Activate ResourcesRecovery scenario managerNew scenario

    NextSelect trigger event pop up windowNextTake the hand icon and click on the desired popup windowNextNext

    Select recovery operation as Keyboard or MouseoperationNextSelect Click button with Label optionTake the hand icon and click on the desired button in thepopup window to be clicked

  • 8/8/2019 QTP Session_ Testing Tools Automation

    42/71

    NextDe-select the check box Add another recoveryoperationNext

    Select Post-Recovery-Test-Run options asRepeat current step and continueNextSpecify a scenario nameNextSelect the check box Add scenario to the current test

    FinishClick on SAVESpecify a file name with .QRS extension (Quick RecoveryScenario)Close. Click on RUN and analyze the results

    b) OBJECT STATE:This trigger event is used for defining a solution to overcome the problematic situation faced by the QTP duringexecution that is related to Object State.Navigation:Resources-> Recovery Scenario manager-> new scenario-

    >Next->Object State->Next->take the hand ICON andclick the pop up window ->OK->Next->if you want to add the properties, click onADD/Remove button, and select the desired propertiesto be addedNext

  • 8/8/2019 QTP Session_ Testing Tools Automation

    43/71

    NextFunction CallNextClick on browse, select the desired .vbs file

    Open -> specify a function nameThen insert the necessary statement in betweenfunction and end functionNextDeselect the check box Add another recovery operationNext

    Select repeat current step and continueNext specify a scenario nameNext select the check box add scenario to current testFinishClick on save specify the desired file name with .qrsextension

    Click on save and click on close and then click run.

    c) TEST RUN ERROR:It is used for defining a solution to over come a

    problematic situation like a step in your test does not runsuccessfully during execution.

    Navigation: Tools->recovery scenario manager->newscenario->Next->Test run error-> select the error type as anyerrorNext->Next->function call->browse the desired VBS file(library)

  • 8/8/2019 QTP Session_ Testing Tools Automation

    44/71

    Next->deselect the check box Add another recoveryoperationNext->Proceed to next step->next->scenario name->nextSelect the check box Add the scenario to the current

    testFinish. Click on Save. Specify a file name and click on Saveand closeClick on run and analyze the results.

    d) APPLICATION CRASH:

    It is used for defining a solution to over come aproblematic situation like the application fails during theexecution.

  • 8/8/2019 QTP Session_ Testing Tools Automation

    45/71

    REGULAR EXPRESSIONS:

    When ever the QTP is unable to identify the object dueto its regular changes in the objects property values

    to over come from that problematic situation thesolution provided is regular expression.

    Whenever the objects properties value is beingregularly changed dynamically then that constantvalue present in the object repository has to bereplaced with a Regular Expression.

    Navigation:

    Open the object repository

    Select the desired test object

    Select the desired property whose value to bereplaced with a regular expression, click on theconstant value options button,

    Replace the constant value with desired regularexpression.

    Select the check box regular expression

    Click on NO

    Click OK

    Change the same thing in the repository also.

    Click OK.

    FRAME WORKS

  • 8/8/2019 QTP Session_ Testing Tools Automation

    46/71

    It is a set of generic guidelines designed by theexperts to accomplish a task in an effective, efficientand in an optimized way.

    There are 4 types of Frame Work:Linear

    Modular

    Keyword Driven

    Hybrid or Sandwich

    1) Linear Frame Work:

    a) Generating the basic script

    b) Enhancing the script

    c) Debugging the Scriptd) Executing the Script

    e) Analyzing the Results

    2) Modular Framework:

    An action is a combination of one or more statementsto perform a specific task that would returns aresulted action.

    Create the components or the Actions

    Make them as reusable Actions

  • 8/8/2019 QTP Session_ Testing Tools Automation

    47/71

    Prepare the drivers based on the end to endscenarios

    Execute the drivers

    Analyze the results

    Reporting

    Navigation for splitting an action into 2actions:

    Save the Action

    Keep the cursor on the first line of thesecond part

    Activate the menu item Edit

    Select the option Action and Split Action

    Select one of the following:

    Independent of each other

    Nested

    Specify the desired name of the Action tosave

    Click OK

    Navigation to make the Actions intoReusable actions

  • 8/8/2019 QTP Session_ Testing Tools Automation

    48/71

    Activate the menu item Edit

    Select the option Action Select ActionProperties

    Select the check box reusable action andclick ok.

    Navigation for creating a new Action:

    Activate the menu item Insert

    Select the option Call to new Action

    Specify the action name

    Select one of the following

    At the end of the test

    After the current StepClick OK

    Navigation for renaming an Action:

    Activate the menu item Edit

    Select the option Action Select Action

    Properties

    Rename to the desired name and click ok.

    Navigation for calling an Existing action:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    49/71

    Activate the menu item Insert

    Select Call to Existing action

    Browsed the desired location

    Select the desired action from the dropdown

    Select one of the following

    At the end of the test

    After the current Step

    Click OK

    Navigation for Calling Copy of Action(used for editing reusable Actions)

    Activate the menu item InsertSelect Call to Copy of action

    Browsed the desired location

    Select the desired action from the dropdown

    Select one of the following

    At the end of the test

    After the current Step

    Click OK

  • 8/8/2019 QTP Session_ Testing Tools Automation

    50/71

    3) Keyword Driven Frame Work:

    Create the SW structure as followed:Create a folder in a desired drive with theprojectName_Auto

    Open the folder and create 7 more sub folderswith the names Library

    Repository Test Test Data Environment Recovery

    LogCreate the desired library files (.VBS or Visualbasic script), Desired Repositories (.TSR or TestShared Repository),Desired Recovery files (.QRSor Quick Recovery Scenario), Desired Test Data,Desired Test and save them in the corresponding

    sub foldersOpen the main TESTAssociate the required resources like libraries,

    repositories, Recovery, Test and Test Data) Hybrid Frame Work:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    51/71

    The combination of Linear, Modular and Keyworddriven is known as Hybrid Frame Work.-End of Frame works-

    REAL TIME ORIENTATION METHODS

    Simple Methods:Click method:

    )

    This is used for Clicking on a specifiedobjectSyntax: Object hierarchy.click[x, y[button]]DBL Click method:This is used for double clicking on a

    specified ObjectSyntax:objectHierarchy.dblclick[x,y[button]]

    Set method:This is used for setting a value into Edit

    box,Selecting or deselecting a check box,selecting an option button (radio button)Syntax for Edit box:ObjectHierarchy.setvalueSyntax for Check Box:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    52/71

    ObjectHierarchy.seton/offSyntax for Option button (Radio button)ObjectHierarchy.set

    CASE STUDY 1:Develop a script for entering the EName,EAge, ESal, EDesignation and clicking onSubmit button.

    Script:Vbwindow(EMP).vbedit(EName).setJayaVbwindow(EMP).vbedit(EAge).set49Vbwindow(EMP).vbedit(ESal).set$100.0

    00Vbwindow(EMP).vbedit(EDesignation).setQAManagerVbwindow(EMP).vbbutton(Submit).click

    CASE STUDY 2:Develop a script for selecting the checkbox for testing tools, live projects, sqlserver in Orbit form and clicking onsubmit button.

  • 8/8/2019 QTP Session_ Testing Tools Automation

    53/71

    Vbwindow(ORBIT).vbCheckbox(TestingTools).seton

    Vbwindow(ORBIT).vbCheckbox(LiveProject).setonVbwindow(ORBIT).vbCheckbox(SQL).setonVbwindow(ORBIT).vbCheckbox(MultiMed

    ia).setoff

    If they have selected any other thanspecified requirements then you have tomake sure that it is not selected.( Above

    EX: multimedia)Vbwindow(ORBIT).vbButton(Submit).click

    CASE STUDY 3:

    Develop a script for entering a Cast, Age,selecting the gender and clicking on searchbutton in form 1.

  • 8/8/2019 QTP Session_ Testing Tools Automation

    54/71

    Vbwindow(From1).vbEditbox(Cast).setAVbwindow(From1).vbEditbox(AGE).set

    50Vbwindow(From1).vbRadioButton(Male).setVbwindow(From1).vbButton(Search).Click

    Select Method:This is used for selecting an item in a combobox or list box.Syntax: objectHierarchy.selectitem nameCASE STUDY 1:Develop a script for entering a name, age,

    selecting from, to, and setting a train numberand selecting the gender and clicking onSubmit button in Res FormVbwindow(Res).vbEdit(Name).set JayaVbwindow(Res).vbEdit(Age).set 49Vbwindow(Res).vbComboBox(To).selectHyderabadVbwindow(Res).vbComboBox(From).selectNew DelhiVbwindow(Res).vbEdit(Train #).set 9

  • 8/8/2019 QTP Session_ Testing Tools Automation

    55/71

    Vbwindow(Res).vbRadioButton(Female).setVbwindow(Res).vbButton(Submit).click

    Activate Method:This is used for activating awindow/application/browserSyntax: objectHierarchy.activateVbwindow(form1).activate

    Close Method:This is used for closing awindow/application/browserSyntax: ObjectHierarchy.closeVbwindow(form1).close

    Set secure Method:This is used for setting an encrypted data intothe Edit Box.Syntax: ObjectHierarchy.setsecureencryptedstring

    Navigation for generating encrypted stringStart->Programs->QTP->Tools->passwordencoderDialogue (login).winEdit(password).setsecureencryptedString

  • 8/8/2019 QTP Session_ Testing Tools Automation

    56/71

    Type Method:It is used for performing any kind of keyboardrelated operations.Syntax: objectHierarchy.type keyvalueDialogue (login).winEdit(passWord).typemicTab(Make sure that there is space between typeand keyvalue)

    GET RO PROPERTY:It is used for getting a runtime objects propertysvalue during the execution.Syntax:Variable = Object Hierarchy.getROproperty(Property name)CASE STUDY 1:Develop a script to select ProductID and to enterthe quantity and to click on the CAL button to checkthe amount manually in form PRODUCT.

    Script:Vbwindow(PRODUCT).vbComboBox(PID).select0077VbWindow("PRODUCT").VBEdit("Quantity").set "9"

  • 8/8/2019 QTP Session_ Testing Tools Automation

    57/71

    R=vbWindow("product").VBEdit("PRate").getROproperty ("Text")Q=VbWindow("product").VBEdit("Quantity").getROproperty ("Text")

    'Expected Value (EV), Actual Value (AV) comments.

    ev = r*qVbWindow("Product").vbButton("CAL").click

    AV =VBWindow("product").VBEdit("Amount").getROproperty("Text")if (EV = AV) then

    reporter.reportevent micpass,"MyReport","Pass"Elsereporter.reportevent micFail,"MyReport","Fail"

    End if

    GET TO PROPERTY:It is used for getting the text objects propertys

    value during the execution.Syntax:Variable = Object Hierarchy.getTOproperty(Property name)

  • 8/8/2019 QTP Session_ Testing Tools Automation

    58/71

    SET TOPROPERTY:

    It is used for setting the text objects propertys valuetemporarily during the execution.

    Syntax:

    Object Hierarchy.setTOpropertypropertyName,propertyValue

    (Space must be there after setTOproperty andpropertyname.)

    COMMONLY USED VB SCRIPT FUNCTIONS:

    CSTR:

    This is used to converting a value into a string

    CBOOL:

    This is used to converting a value into a Boolean value

    CINT:

    This is used to converting a value into an integer value

    CDBL:

    This is used to converting a value into a double valueor float

    LTRIM:

    This is used for trimming the left side spaces

  • 8/8/2019 QTP Session_ Testing Tools Automation

    59/71

    RTRIM:

    This is used for trimming the right side spaces

    TRIM:This is used for trim both side spaces

    MID:

    This is used for returning a sub-string

    LEFT:

    This is used for returning a LEFT sub-string

    Dim a, b

    a = I am Great in Testing

    b = Left (a, 8)

    msgbox(b)

    RIGHT:

    This is used for returning a RIGHT sub-string

    Dim a, b

    a = I am Great in Testing

    b = Right (a, 8)

    msgbox(b)

  • 8/8/2019 QTP Session_ Testing Tools Automation

    60/71

    ROUND:

    This is used for rounding a decimal value to nearestinteger

    CEALL:

    It is used for ceiling the value (Highest nearest integeris Ceiling)

    FLOOR:It is used for flooring the value. (Lowest nearest

    integer)

    DATA TABLE METHODS

    Add Sheet Method:This is used for adding a specified sheet to aruntime Data Table.Syntax:DataTable.AddSheetSheetName

    Delete Sheet Method:This is used for deleting a user defined sheet froma runtime Data TableDataTable.deleteSheetSheetName

  • 8/8/2019 QTP Session_ Testing Tools Automation

    61/71

    Import Method:This is used for importing all the sheets in an Excelfile to a runtime Data tableSyntax:Datatable.importFullPath with a file name .xls

    extension)Import Sheet:It is used for importing a specified sheet from an

    Excel file to a specified location in the runtime DataTable.Syntax:

    Datatable.importsheetFull Path, source Sheet ID,Destination Sheet ID

    Export Method:It is used for exporting all the sheets in theruntime Data table to a specified location in thehard DiskSyntax:

    Datatable.exportPath of the location with the filename .xls extension

    Export Sheet Method:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    62/71

    It is used for exporting a specified sheet from theruntime Data Table to specified location in the harddiskSyntax:Datatable.exportsheetPath of the location withthe file name .xls extension, sheetID

    Set current Row Method:This is used for setting the focus of QTP to

    specified ROWSyntax:Datatable.setcurrentROW(ROW number)

    Set Next Row Method:It is used for setting the QTPs focus to the nextROW of the currently focused ROWSyntax:Datatable.setNextROW

    Set Previous Row Method:

    Syntax:Datatable.setPreviousRow

    Get Sheet Method:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    63/71

    It is used for making the QTP focus on a specifiedsheetSyntax:Datatable.getSheet(sheetId)

    Get Row count method:It is used for getting the ROW count of a sheet bydefault it will get the ROW COUNT of the Globalsheet. If one needs to get the ROW COUNT of a

    specified sheet, first we need to focus the sheet,then get the ROW COUNT.

    Syntax for getting the ROW COUNT of the GlobalSheet:Variable=datatable.getRowCount

    Syntax for specified sheetVariable = datatable.getsheet(sheet ID.getRowCount)

    DESCRIPTIVE PROGRAMMING

  • 8/8/2019 QTP Session_ Testing Tools Automation

    64/71

    If the description is described in the program itself then itis known as DESCRIPTIVE Programming.

    Script:

    Dialog("Text:=Login").WinEdit("Attached Text:=AgentName:").Set "Jaya"Dialog("Text:=Login").WinEdit("AttachedText:=Password:").SetSecure"47257f2ff7200f866a1a9285db8ad6dac9bd7932"Dialog("Text:=Login").WinButton("Text:=OK").Click

    ENVIRONMENT VARIABLESIt is concept provided by QTP to declare anddefine Variable once and use them in themultiple tests in the same environment.There are two types of Environment Variables.A) Built in Variables, B) User defined Variables.

    A)Built in Variables:These are the variables already declaredand defined by the QTP and associate toeach and every new test so that one canuse them directly in the script usingfollowing Syntax:Environment.value(VariableName)

  • 8/8/2019 QTP Session_ Testing Tools Automation

    65/71

    B)User Defined Variable:Apart from built in variables, if the userwants to declare and define a variable

    which can be used commonly across manytests then he can declare them as Userdefined Variables. If the Variables aredeclared in the TEST then it is known asInternal Variables. If the Variables are

    imported from an External file, thenthose Variables are called as ExternalVariables.

    Navigation for Declaring and Defining

    Variables:Activate the menu item FileSelect the option settingsSelect Environment TabSelect the Variable type as user defined

    Click on plus buttonDefine the variable and the valueIf needs to exports the variable thenclick the export button

  • 8/8/2019 QTP Session_ Testing Tools Automation

    66/71

    Specify the file name with .xmlextension. (XML files)If order to avoid the above navigation

    one can directly prepare the followingXML file in Note pad.

    Format for creating ExternalEnvironment Variables in XML:

    SAI

    9

    X

    7

    Navigation for Associating the ExternalVariables:Activate the menu item FileSelect the option settings

  • 8/8/2019 QTP Session_ Testing Tools Automation

    67/71

    Select Environment TabSelect the Variable type as user definedSelect the check box load variables and

    values from external fileClick on browse; Select the desired XMLfileClick on Open, click on Apply and click OK

    Syntax: EX:VbWindow("Form1").VbEdit("val1").Setenvironment.Value("SAI")VbWindow("Form1").VbEdit("val2").Setenvironment.Value("X")

    VbWindow("Form1").VbButton("ADD").ClickVbWindow("Form1").VbButton("SUB").ClickVbWindow("Form1").VbButton("MUL").Cli

    ckVbWindow("Form1").VbButton("DIV").Click

  • 8/8/2019 QTP Session_ Testing Tools Automation

    68/71

    INPUT/OUT PUT PARAMETERS

    It is a concept provided by QTP in order

    to serve the purpose of passing thevalues into the action and to get somevalues from the action. For doingthe same QTP has provided input/outputparameters.

    Note: These parameters have to bedeclared at the action which is about tobe called.Navigation for declaring Input/outputparameters:

    Edit->Action->Action Properties->Parameters tab->click on + and declarethe input Parameter. Select theparameter type and specify the value.Click on the + button on the output

    parameters, specify the Outputparameter name and select theparameter type and click on OK.

    Syntax:

  • 8/8/2019 QTP Session_ Testing Tools Automation

    69/71

    bWindow("Form1").VbEdit("val1").Setparameter("A")VbWindow("Form1").VbEdit("val2").Set

    parameter("B")VbWindow("Form1").VbButton("ADD").Clickparameter("D")=Vbwindow("Form1").VbEdit("Res").G

    etROProperty("Text")

    BATCH TESTINGTest Batch Runner:

    It is awesome concept provided by QTPto execute a group of tests at a time. Fordoing the same QTP has provided aseparate tool known as TEST BATCHRUNNER.

    Note: in QTP you have to do the followingmodificationsTools->Options->Run Tab->select thecheck box

  • 8/8/2019 QTP Session_ Testing Tools Automation

    70/71

    Allow Other Mercury products to runtest and componentsNavigation:

    Start -> Programs->QTP->Tools->TestBatch RunnerClick on Add and add the desired test,Click on save. Specify a file name with.mtb extension (mercury Test Batch)

    When ever needed open the saved .mtbfile and run.

    Database Connections

    Dim con, rsSet con=createobject(adodb.connection)Set rs=createobject(adodb.recordset)Con.provider=Microsoft.jet.oledb.4.0Con.open=D:\nagesh\database.mdb(give the

    path of the database)Rs.openselect*from DATABASE TABLENAME, con (give the name of the table)Do while not rs.eof (end of file)

  • 8/8/2019 QTP Session_ Testing Tools Automation

    71/71

    Vbwindow(form1).vbedit(val1).setrs.fields(v1)

    Vbwindow(form1).vbedit(val2).set

    rs.fields(v2)Vbwindow(form1).vbbutton(add).clickrs.movenext

    Loop-----------------------------------END of Automation----------------------------------