QTP CLASS2

50
Recording of Scripts Different modes of Recording in QTP There are three modes Normal Recording Mode Low Level Mode Analog Mode.

description

QTP Software

Transcript of QTP CLASS2

  • Recording of Scripts

    Different modes of Recording in QTP There are three modes Normal Recording Mode Low Level Mode Analog Mode.

  • Normal recording: In normal recording time QTP records user operations with respect to the application GUI object. while recording QTP uses object identification (recognized the application object) and the object repository.In normal recording QTP records mouse click, key board inputs and application information. Analog recording : These recording option will be selected in case to record the mouse track moments of the application.Analog recording can be performed in two waysRecord relative to the screenRecording relative to the windowThe first option QTP generate the statement with respective to the screen coordinate(desk top).Script statement: desktop. Run analog track

  • In the second option QTP generate the statements with respect to the specified window coordinates.Script statements: window (paint).Run analog TrackNote1:in analog recording QTP uses object repository and object identification tools similarly in normal recording.Note2:Analog recording will be prefer in case of digital signature, Image drawings, or Bit map drawings or graphs.Low level Recording: In low level recording QTP records the user action with respect to the objects and it does not use object identification capability.In low level recording all the GUI objects of the application will be record as window or win object.In low level recording QTP records the mouse click with screen track or coordinate moments( Including the mouse location).Note: Low level recording tracks the screen coordinate for click operation perform on object hence if the resolution change the script might fail.

  • What is a Checkpoint?

    Check point is the verification point which can hold the expect value. In run time the QTP captures the actual value from the application and report the result as pass or fail.Process: convert the base line test case into the script file.Provide expected value in the test case as check pointRun time QTP capture actual value of application and compare with check points(expect value).Provide the result pass or fail

  • The expected value can be property of an image or web page or a table with values displayed in application, portion of text or text displayed in a specified region, a dynamic value displayed in application from database, bitmap of image displayed or dynamic text displayed from XML.

    Check points are Classified as under:Standard CheckpointPage CheckpointText / Text Area CheckpointImage CheckpointDatabase CheckpointXML CheckpointBitmap CheckpointTable CheckpointAccessibility Checkpoint

  • Standard Checkpoint: Standard Checkpoint checks for property value of object displayed in any application. Object can be radio button, combo boxes, drop downs, button, images and links. A user who records a standard check point can select the properties of any property he wishes to check. QTP will check only the fields specified by the user. The value column is stored as expected result and can be modified or parameterised when creating and modifying checkpoint. Expected resultIf the value in the application is displayed as a table then this check point is called as Table Checkpoint. User can select few values in the table or select all the values as expected value. User also has options to parameterize the values.

  • Page Checkpoint: A Standard Checkpoint created for a web page can be called a Page Checkpoint. Page Checkpoint includes checking Load time, number of images or links in a web page, checking every links and images, HTML Source and Tags verification and checking for broken lines. Load time: The time taken by a web page to load. A user who uses this check point can give approximate amount of time that will be required for the page to load so that QTP will fail this checkpoint when page takes more time to load than specified. Number of links and images present in a web pageConsider this a web pageQTP Results:No of Links: 6No of Images: 4

  • Checking links and images: User can check all the links and images present in his application with the links and images expected with a page checkpoint. Checkpoint results will show the expected and actual result obtained as shown below.-

  • Text/Text Area Checkpoint: Checks the text present in a web page or any application. We can store the expected text that should be present in the application when creating this checkpoint. QTP verifies whether the expected text with the actual text appearing and shows output as shown below.Text Checkpoint can check for case sensitivity, space mismatches and for exact matches. These three options can be configured by the user as shownExpected result is shown in green color and actual content that captured in the web application is shown in red color. A text mismatch will be shown as represented above. Options will be provided to the user to export the contents to excel sheet in the same format

  • Database Checkpoint: Compares the dynamic values displayed in the application with the values from the database. User will write a SQL query when creating this checkpoint with which QTP will check the dynamic values displayed in application.Software Testing India

    Total number of Client: 10Total number of employees: 2500Total number in onsite: 200Number in offshore: 3200ApplicationDynamic values from databaseQuery written in QTP to check random values:Select * from data where company = Software Testing; Values retrieved from database by QTPCl_numemp_numon_numoff_num1025002003200

  • Database Checkpoint: Compares the dynamic values displayed in the application with the values from the database. User will write a SQL query when creating this checkpoint with which QTP will check the dynamic values displayed in application.Software Testing India

    Total number of Client: 10Total number of employees: 2500Total number in onsite: 200Number in offshore: 3200Dynamic values from database7000700Query written in QTP to check random values:Select * from data where company = Software Testing Genius; Values retrieved from database by QTPCl_numemp_numon_numoff_num1025002003200

  • XML Checkpoint: In web application, there will be several places for which data from XML will be displayed . QTP helps in comparing the values in the XML with the values displayed in application and also can validate the schema of XML. The contents displayed in a web application from XML is checked Expected input values can be parameterized XML Schema can also be validated with the checkpoint

  • Bitmap Checkpoint: A Bitmap checkpoint helps a user in checking bitmap of an image or a full web page. Usually users should create record this checkpoint in prototype and will use the application for running. QTP will check whether the expected bitmap which is recorded previously exists in the application and provide us with appropriate results.Mismatch!Bitmap CheckpointFailed

  • Types of Check Points

  • Inserting Check PointsRight Click the object and select Insert Checkpoint.

  • Analyzing a Test with Check PointsCheckpointFailedCheckpoint Passed

  • Object Repository Type and Object Recognition

    What is an Object Repository ?Object Repository is a collection of objects pertaining to the application under test. Example: All the text boxes, list boxes, images etc are stored in a file in QTP. This file is called the object repository. Each object will have the set of properties to identify that object uniquely in the application. At the time of execution, QTP identifies the objects on the screen by comparing them with We can have any number of Shared Object Repositories associated with an action. In QTP 10.0 all the objects are recorded into the local repository and then we need to export the objects from local repository into the shared object repository by opening the object repository and selecting File Menu and selecting "Export Local Objects". We need to specify the name for the shared object repository in which we want to save these objects.the objects and their properties in the repository.

  • Types of Object Repository Per action object repository Shared object repository

    Per action object repository Default repositorySpecific to actions (Will be used only for a particular action)Preferable when application is not dynamic with respect to timeCannot be reused

  • Object Repository Type and Object Recognition

    Per action object repository Default repositorySpecific to actions (Will be used only for a particular action)Preferable when application is not dynamic with respect to timeCannot be reused

    Example Action1 and Action 2 of same test will have different object repositories.

  • Object Repository Type and Object Recognition

    Shared Object Repository Can be updated by all actions accessing it Preferable when application is dynamic with respect to time Used in most automation projects Needs maintenance and administration

  • Object Repository Type and Object Recognition

    Shared object repository may be common to all tests and to all actions inside each testShared object repositoryTest1Test2Test3Action1Action 2Action3Action1Action2Action3Action1Action2Action3

  • Object Repository Type and Object RecognitionWhat is Object Identification?Object identification is a method of instructing QTP to recognize the various objects in the application.Usually QTP can identify the objects uniquely for most of the applications/objects, but for some applications this may not be true.In this scenario we need to tweak the Object Identification settings of QTP to learn extra properties or custom properties defined in the application, for recognizing the objects uniquely.

  • Object Repository Type and Object Recognition

    How to do Object Identification in QTP?

    Go to - Tools - Object identification - and select the environment (windows, web etc).

    This will give you all the possible type of objects in that environment like Edit boxes, check boxes etc.

    Select the type of object you have problem recognizing uniquely.

    QTP will show you the mandatory and assistive properties which are grabbed and used currently for that object.

    You can select the extra properties which are already defined in the application for that kind of object by clicking on the green "+" sign and selecting the required properties.

    If you still have the problem of recognition then you need to find out the unique property defined for that object type from the development team and Add that custom property by clicking "New" in the Add/Remove properties window of Object identification.

  • Object Repository Type and Object Recognition

    How to do Object Identification in QTP?

    If you still have the problem of recognition then you need to find out the unique property defined for that object type from the development team and Add that custom property by clicking "New" in the Add/Remove properties window of Object identification.

    For example if the custom property name is "RefGen", you can click "New" and give the new property name as "attribute/RefGen".

    When you record next time on that kind of object the new properties will be automatically grabbed.

    If you want to update the existing objects run the test in the Update Run mode and select the checkbox Update Object Properties. Note: The changes you make in the Object Identification will affect everyone working on that machine. These changes should be applied universally on all the machines you intend to run the regression tests. These are QTP setting changes not the script changes.

  • Object Repository Type and Object Recognition

    Object Identification User can specify properties to be used for identification to distinguish between 2 - objects of sameclass object.

  • Object Repository Type and Object Recognition

    Configuring Mandatory and Assistive Recording Properties: Mandatory properties:

  • Object Repository Type and Object Recognition

    Mandatory properties: QTP has list of mandatory properties, for each type of object, which it always learns. When we run the script QTP uses all the mandatory properties to identify the object. It uses assistive properties when mandatory properties are not enough to identify an object.

  • Object Repository Type and Object Recognition

    We can change the mandatory properties or assistive properties based on the application.We can add /remove few properties in mandatory properties or assistive properties so that QTP identifies the object when we run the script

  • Object Repository Type and Object Recognition

    How to change properties of objects? Tools Object Identification Object Identification dialog box opensSelect the properties you want to make mandatory or assistive by selecting the option

    Options are available to the user

    Selected properties will be made mandatory in this case

    Selection of properties should be based on nature of application

    Same is applicable to assistive properties

  • Object Repository Type and Object Recognition

    ExampleRecordingRecording a linkMandatory Properties:Html tag: Text:Inner Text:Assistive Properties:Coordinate X:Coordinate Y:URL:Color:Font:During recording QTP has stored both the mandatory as well as assistive properties for identifying the particular link.

    Let us check why?

  • Object Repository Type and Object Recognition

    During RecordingMandatory Properties:Html tag: Text:Inner Text:Assistive Properties:Now QTP is able to identify the link with captured 3 Mandatory properties and 5 Assistive properties!!Coordinate X: 234Coordinate Y: 286URL: www.abcd.comColor: OrangeFont: ArialQTP uses Assistive properties if the stored Mandatory properties are not enough to identify an objectIncludes 3rd PropertyIncludes 2nd PropertyIncludes 1st PropertyStarts using assistive properties and checks object4th5th

  • Object Repository Type and Object Recognition

    Selecting an Ordinal Identifier: In addition to mandatory properties and assistive properties, QTP records backup ordinal identifier for each test object Used when QTP is not able to identify an object with captured mandatory properties and assistive properties during recording, In other words, Ordinal identifier is used if mandatory properties and assistive properties captured by QTP is insufficient to identify an object in the application during record session. During a Record Session

    If mandatory properties and assistive properties are insufficient to identify an object during record sessionQTP uses Ordinal Identifier in addition to other captured properties to identify the objects during a record session

  • Object Repository Type and Object Recognition

    Types of Ordinal identifiers: Index basedLocation basedCreation Time

    Index: Indicates the order in which the object appears in the application code relative to other objects. Eg., pressing a tab and giving numbers to objects Location: Indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description CreationTime (Browser object only): Indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description. An ordinal identifier is selected by default for each test object class. To modify the selected ordinal identifier, select the desired type from the Ordinal identifier box.

  • Object Repository Type and Object Recognition

    Setting up which ordinal identifier to use during object identification: User can select which ordinal identifier to be used by selecting the options in object identification The ordinal identifier in web will have three options namely Index, Location and Creation time. This Creation Time is not available in the ordinal identifier options of other environments.

    Options for WebOptions for other EnvironmentsIdentifying an Object Using the Index Property: QuickTest can assign a value to the Index test object property of an object The value is based on the order in which the object appears within the source code. The first occurrence is 0.

  • Object Repository Type and Object Recognition

    Identifying an Object Using the Location Property:During recording, QuickTest can assign a value to the Location test object property of an object in order to uniquely identify the object. The value is based on the order in which the object appears within the window, frame, or dialog box, in relation to other objects with the same properties. First occurrence value = 0 Values are assigned in columns from top to bottom, and left to right.

    Example:Numbered based on location property

  • Object Repository Type and Object Recognition

    Identifying an Object Using the CreationTime Property :During recording, QuickTest is unable to uniquely identify a browser object based solely on its test object description, it assigns a value to the CreationTime test object property. This value indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description. During the run session, if QuickTest is unable to identify a browser object based solely on its test object description, it examines the order in which the browsers were opened, and then uses the CreationTime property to identify the correct one.ExampleOpening a new browser with an applicationOpening a new browser with same applicationQTP notes the creation time of both browsers as creation time property

  • Object Repository Type and Object Recognition

    Configuring Smart Identification: Configuring Smart Identification properties enables you to help QuickTest identify objects in your application, even if some of the properties in the object's recorded description have changed.

    About Configuring Smart Identification: QTP uses object description for identifying an object. If its not able to identify the object with the description, then it goes for smart identification mechanism. Smart identification uses two types of properties and are base filter properties and optional filter properties

  • Object Repository Type and Object Recognition

    Base Filter Properties: Most fundamental properties of object class or values which cannot be changed without changing the essence of the original object. Eg., if a Web link's tag was changed from to any other value, you could no longer call it the same object.

    Optional Properties: Other properties to identify objects for a particular class as they are unlikely to change on regular basis, but can be ignored if they are not applicable.

  • Object Repository Type and Object Recognition

    Step-by-step Instructions for Configuring a Smart Identification Definition: Tools > Object Identification. The Object Identification dialog box opens.Select the appropriate environment in the Environment list. The test object classes associated with the selected environment are displayed in the Test object classes list.Select the test object class you want to configure.Click the Configure button next to the Enable Smart Identification check box. The Configure button is enabled only when the Enable Smart Identification option is selected. The Smart Identification Properties dialog box opens:

  • Object Repository Type and Object Recognition

    Base filters & Optional filters:In the Base Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for base filter properties opens. Select the properties you want to include in the Base Filter Properties list and/or clear the properties you want to remove from the list.

    Click OK to close the Add / Remove Properties dialog box. The updated set of base filte properties is displayed in the Base Filter Properties list. In the Optional Filter Properties list, click Add/Remove. The Add/Remove Properties dialog box for optional filter properties opens. Same applies for optional properties also. Use the up and down arrows to set your preferred order for the optional filter properties.

  • Object Repository Type and Object Recognition

    What is a Virtual Object and it helps in solving Object Recognition Problem in QTP ?Virtual Objects comes into picture if QTP is unable to recognize an object and we often see errors as Object not found. This is because even thought you have recorded the actions during playback time QTP is unable to recognize an object and because of which the script fails.Virtual Objectsin QTPare created to resolve the object recognition problems in QTP. When an area of an application is not recognized by QTP we use theVirtual Object Wizardto map the area to a standard Class. These virtual objects are generally used to resolve the object recognition problems. All the Virtual Objects created are stored in theVirtual Object Manager. After we have learned an object as a Virtual Object we can record on that object successfully. You can create aVirtual Object by navigating to Tools, Virtual Objects, New Virtual Object.By creating virtual objects, user can avoid scenarios which may stop automation of a test scenario. E.g.., Try creating a cell in excel sheet as Virtual Object and try recording it and check the script The following example clicks the "button" VirtualButton.

    Syntax: Browser(X").Page(Y").ActiveX(Z").VirtualObject(A").Click

  • Object Repository Type and Object Recognition

    Defining a Virtual Object:Click Tools > Virtual Object > New Virtual ObjectYou will get the steps as mentioned belowClick NextClass can be Object, Button, Table, List, Check box & Radio button.Mark a class based on the object which is present in his application Eg., Mark radio button from the drop down shown if QTP has failed to identify a radio button in the application during recording a scriptNext page for next step

  • Object Repository Type and Object Recognition

    Click Mark Object button (The QTP screen is minimized)You will get a cross hairs pointerUse the cross hairs pointer to mark the object in applicationYou can select entire parent hierarchy or parent onlyStep5Add virtual object to a collectionStep6Step3Step4

  • TransactionsHow do you measure the requires script execution time by using QTP?We can measure the require block of script statements at execution time by providing start transaction and end transaction.They might be the case in which you need to calculate the time take by the qtp to execute a block of statements on the application, these can be achieved using transaction in QTP.Transaction is a feature of QTP which calculate the time taken to execute a block of statements and reports the time to QTP Result.The block of statements have to be enclosed with start transaction statement like as below

    Syntax: Service. Start transaction login------------------------------------------------------------------------------------------------------------ service. end transaction login

  • Implement transaction through programming algorithm

    Capture the current lineExecute the block of statementCapture the time after executing the statementsCalculate the difference between the two times and report it to the qtp resultDate Function: It capture and returns the current system date syntax: date function =date=>msgbox dateNow function: It Capture current system date and time syntax: Now Function = Now=> Msgbox nowDate diff: It returns the difference between two date w.r.t interval specified syntax: date difference Msgbox Now = date diff (,date1,date2)To calculate the time in milli secod the NOW Function cant perform task than we have to depend on mercury timer object.

  • Note: Mercury time object an internal timer object that measure the time in milli secondStart Method: It Start the timer Mercury timer().startStop method: It stops the timer Mercury timer().stopElapsed Time property : It returns the time in milli second since the timer as started = Mercury timer().elapsed time

  • SynchronizationSome times when u run the test your application may not always respond with the same speed at which QTP is executing the script.(application speed is not matching with the QTP Script executing speed)These might causes the test script to be fail such issue can be handle using synchronization.Synchronization: synchronization is the process of controlling the script execution speed according to application respond is called as synchronization.Using synchronization we instruct QTP to be wait untill a certain event happenThey are three ways in which we can implement synchronizationUsing exit()&wait statementChange in the default time out settingsUsing synchronization pointWait():It accepts the time in seconds as the default as input parameter. It can be applied any where in the script.Its scope will be local(It applicable to that script)

  • It is for that specified time even if and application is ready QTP will continue to wait for specified amount of time.Change in default timeout settings: The QTP default time out is 20 sec in case of window application in case of web application QTP waits for a maximum time of 60 secThese option will be consider when the application objects are not ready within the specified waiting timeIn case of default setting QTP waits for required amount of time that u specify.Note: It is a global setting for every test execution the tool will wait for same time. So delay can be possible.Synchronization point:It is a dynamic time settings which can go to adjust the time of the tool based on the application conditionSynchronization point will be attach with a maximum wait time to avoid in define time.In these process the tool will be wait untill the property of a specifc object achieves the specified value within the specified time out.

    Syntax:.waitporperty,,,

  • Testing methodologies