How to get the count of links, images, buttons and edits in a web page using QTP

Write a Script to get the count of all the edits, images, buttons and links in a web page.

Before running the script in QTP the user needs to add the web page in the Object repository. Here we are using using differnet functions for each item to get the values.  


Function GetAllSpecificControls(Page, MicClass) Set Desc = Description.Create()
Desc("micclass").Value = MicClass
Set GetAllSpecificControls = Page.ChildObjects(Desc)
End Function

        Function GetAllEdits(Page)
        Set GetAllEdits = GetAllSpecificControls(Page, "WebEdit")
        End Function

             Function GetAllButtons(Page)
             Set GetAllButtons = GetAllSpecificControls(Page, "WebButton")
             End Function

Function GetAllLinks(Page)
Set GetAllLinks = GetAllSpecificControls(Page, "Link")
End Function

Function GetAllImages(Page)
Set GetAllImages = GetAllSpecificControls(Page, "Image")
End Function

Set oPage = Browser("Browser Name").Page("Page Name")
MsgBox "Number of Edits: " & GetAllEdits(oPage).Count
MsgBox "Number of Buttons: " & GetAllButtons(oPage).Count
MsgBox "Number of Links: " & GetAllLinks(oPage).Count
MsgBox "Number of Images: " & GetAllImages(oPage).Count

How to get the count of drop down values in QTP

Write a Script to get the count of the drop down items and then print the drop down values in an excel sheet from QTP.

Before running the script in QTP the user needs to add the dropdown box in the Object repository. Here we are using excel application object so that QTP creates and excel application. We are setting the excel application to be visible so that during run time we can see exactly whats happening. GetROProperty Item Count actaully counts the total number of items in the drop down during run time. Once this count is received we will pass them in a loop so that we can pass them to the excel sheet to be added one by one. msgbox is kept in the loop just to see that each item is being retreived. 


'Initializing an array with 3 columns and 4 rows

Dim Eobj Set Eobj= createobject ("Excel.Application")
Eobj.visible = true
Eobj.workbooks.add

Set obj = description.Create()
obj= Browser("Browser").Page("Page").Frame("Frame").WebList("city").GetROProperty("Items Count")
For i=1 to obj
obj2= Browser("Browser").Page("Page").Frame("Frame").WebList("city").GetItem(i)
Msgbox obj2
Eobj.cells(i,1).value = obj2
Next

Eobj.Activeworkbook.Saveas("c:\citylist.xls")

Eobj.quit

Automation Testing

Automation is the buzz work in today’s testing world and every one are moving to automation and in the market there are many automation tools and the popular are HP QTP, IBM RFT, open source tools like Selenium and many others.

In order to enter the field of Automation Testing let us understand what automation is all about and why automation is needed. Find below some quick glance on Automation.

1. Overview of Automation: Automation is preferred in below cases.

-    Redundancy
-    Avoid Manual misses and assumptions
-    Reduce Cost
-    Reduce execution time
-    Unattended automation
-    Good ROI [Return On Investment]

2. Overview of  Framework: Framework is a concept/template/structure.


3. Types of Frame Work

Data Driven Framework

Depends on Test Data
User can provide the Test Data
QTP can auto generate the test data as well

Keyword Driven Framework

This require excel sheet till QTP version 9.2
This is in-built in QTP version 9.5
Sample script:

function func_add (i,j)
i=2
j=3
z=i+j
msgbox z
End function
Functions are stored in Function.qfl

Hybrid Framework

This is the combination of Data Driven and Keyword Driven.

How to set Internet Explorer as the default browser in Windows XP SP1 and above for QTP

It has been seen that if there are more than one browser in a machine and unknowingly if a  different browser is made default than Internet Explorer then when executing a script in QTP which requires to open an application in a browser it would become difficult if you use QTP versions less than version 10.

There is a way to set the Internet Explorer as default browser. Following are the ways to set the browser.

1. This can be done by using the Set Program Access and Defaults feature in windows to set the default browser. To set Internet Explorer as the default which also repairs the file association settings try the following method:

From the Control Panel click on Add/Remove Programs then choose the Set Program Access and Defaults button. Click the Custom button once. From the list that appears, select Internet Explorer and then click the OK button.

2. Another way is to directly click Start and Run. In the Run window type control appwiz.cpl,,3
The Add or Remove Program window will open.  Click the Custom button once. From the list that appears, select Internet Explorer and then click the OK button.


QTP Interview Questions-I

QTP Basic Features


1) What are the advantages in Test Automation using a Tool?

a) Fast: Test Tool runs tests significantly faster than human users.

b) Reliable: Automation tool can perform the same operation each time, if we repeated multiple times, so that we can eliminate human errors.

c) Repeatable: We can check how application or website reacts after repeated the same operation with multiple times.

d) Reusable: Automation scripts are reusable on different version of the application of websites even if the user interfaces changes.

e) Comprehensive: In automation testing we can build a suit of tests that covers every feature in the application or website.

f) Programmable: We can program sophisticated Tests that bring out hidden information from the application

2) What are the drawbacks in Test Automation?

a) It is expensive.

b) We cannot automate all areas.

c) Lack of Skill.

d) It has some limitations (It cannot test every thing).

3) What type of test tools available in the industry?

We can segregate Test tools in 2 categories

1) Business Classification

a) Vendor Tools

b) Open Source Tools

c) In-house Tools

2) Technical Classification

a) Functional and Regression Test Tools

b) Load/Stress/Performance Test Tools

c) Security Test Tools

d) Test Management Tools

e) Unit Test Tools

f) Requirement Management Tools Etc...

4) What are the important factors in test tool selection?

1. Technical factors:


a) Nature of the AUT (Application Under Test)

b) Tool Features (Facilities available)

c) Availability of Skilled professionals

d) Organizations experience

e) Technical support from vendor

2. Business factors:

a) Budget

b) Vendor’s Reputation

c) Client’s Interest

5) What test cases can be automated?

Test cases that we want to execute on number of versions of the software. Ex: Regression test cases

Test cases that we want to execute with multiple sets of data. Ex: Data driven test cases

Test cases having complex functionality

6) What test cases cannot be automated?

Dynamically changing functionality

Test cases that require more Human interaction.

CUI (command user interface) based test cases.

7) Explain about the Testing process in QTP?

Planning:

• Analyzing the Application

• Automation Framework Implementation

• Selecting/Generating Test cases for Automation

• Collecting Test Data

• Configuring Tool Settings

Generating the basic tests

Using Object Repository method or using Descriptive Programming, we can generate Tests

Enhancing Tests

With respect to our project requirements, we have to enhance our tests. For enhancing tests QTP is providing various features like:

Inserting Transaction points

Synchronization

Parameterization

Inserting VB script Flow Control statements

Adding comments

Calling Functions/ calling Actions

Using Environment variables

Entering Regular Expressions

Inserting Checkpoints

Inserting Output values

Note: For any Test all enhancement methods not required.

Debugging Tests (if required)

It is optional; basically scripting languages are Light weight languages, no need to compile them separately. During execution Scripts can be compiled and Run.

If we have any doubts about some scripts, then we can execute them step by step with the support of VBScript Debug commands and Break points.

Running tests

Generally, many companies are using Framework feature for Running Tests.

QTP Supports many kinds of test execution like Individual Test execution, Batch execution which means you can run many scripts by forming a batch, Tests execution through AOM Scripting, and Scheduled execution i.e setting up a certain time or configuring the test with the support of Windows Operating system to set up time when the script should execute.

Analyzing Results

It is not the Responsibility of QTP; Test engineer has to do this manually.

QTP is providing Result window in XML format.

QTP is providing Result deletion tool also.

QTP is providing Test results exporting facility. It supports HTML, Word document and PDF (portable document format) formats.

Reporting Defects

Reporting defects of a Application under Test is not a QTP responsibility. Reporting of defects should be done manually after analyzing the test results, but if Quality Center is used then from the QTP result window the defects can be send directly..

8) What types of License available for QTP?

a) Seat License or Node locked

Fixed for one System (Machine), we can use from that System only

b) Concurrent License or Floating License

This License, we can use from different Systems but one at a time

9) What are the QTP supported environments?

QTP Supports Software Applications based on Add-ins only. Add-in means Technology supporting files. QTP Add ins available for following technologies:

a) Default Add ins

1) Activex

2) Visual Basic

3) Web

b) Other Add-ins

1) Delphi

2) Java

3) .NET Web forms

4) .NET Windows forms

5) WPF (Windows Presentation Foundation)

6) Oracle

7) People Soft

8) Power Builder

9) SAP for Web

10) SAP GUI for windows environment

11) Siebel Environment

12) Standard Windows

13) Terminal Emulator (TE)

14) Visual Age Smalltalk Environment

15) Web Services Environment

10) Does QTP Support UNIX Environment?

No, QTP doesn’t support UNIX/Linux Environment, Supports Windows Operating Environment only, but LoadRunner and Quality Center have support both Windows and UNIX Operating Environments.

11) What scripting language is used in QTP to applying programming logic?

Micro Soft Visual Basic Scripting edition (VBScript) engine embedded with QTP.

12) Does QTP Support Database Testing and Data driven Testing?

Yes, SQL Engine embedded with QTP Tool, so we use SQL Statements directly in QTP Test Pane as well as in Function Library. QTP has an integrated Spread sheet(Excel like) for Performing Data Driven Testing, otherwise we can fetch test data directly from external files and databases using VB Script.

Write a Script to open an excel workbook through VB Scripting

The below vb script will open an excel work book for which the path is mentioned.
set xl = CreateObject("Excel.Application")
xl.visible = true
set wb = xl.workbooks.open("C:\test.xls")
wb.close
xl.quit

Child Objects in QTP scripts with examples

Many at times in Scripting we come across scenarios where we need to count the objects in the application or even highlight a child object like highlighting a text box or check and uncheck check boxes using scripting in QTP.

Below are some of the examples where in you can do different actions. For our example we are using Flight Reservation application as reference.


'Script to count the number of child objects of flight reservation application
Set chd_obj = Dialog("text:=Login").ChildObjects
msgbox chd_obj.count

'Script to highlight all the child objects in Login dialog of flight reservation application
Set chd_obj = Dialog("text:=Login").ChildObjects
For i = 0 to chd_obj.count - 1
chd_obj(i).Highlight
Next

'Script to highlight all the child objects(buttons) in Login dialog of flight reservation application
Set button_obj = Description.Create
button_obj("nativeclass").Value = "Button"

Set chd_obj = Dialog("text:=Login").ChildObjects(button_obj)
For i = 0 to chd_obj.count - 1
chd_obj(i).Highlight
Next

'Script to check and uncheck all the check boxes in open order dialog box of flight reservation application
Set checkbox_obj = Description.Create
checkbox_obj("Class Name").value = "WinCheckBox"

Set chd_obj = Window("text:=Flight Reservation").Dialog("text:=Open Order").ChildObjects(checkbox_obj)
For i = 0 to chd_obj.Count - 1
chd_obj(i).Set "ON"
chd_obj(i).Set "OFF"
Next

Write a Script to delete all the spam mails in Gmail

We will write a script in QTP for deleting all the spam mails in Gmail Account. What we will do is first we will get the innertext of the Spam Link using GetROProperty so that if there are no spam mails then we will exit the test using ExitTest method or can use ExitAction method if we want to only exit that particular action.


If there are spam mails then we will count the unread spam mails and then display it to the user and then delete all the spam mails by checking all the check boxes and clicking the delete forever button. To check all the check boxed we will create a description object and add properties to it WebCheckBox Property. We will use the Childobjects method to get all the checkboxes and using the count method we will get the number of checkboxed. By using a For loop we will set the Checkbox to On so that all will be selected and then click the Delete Forever button to delete the mails.

'Script to Delete spam messages from Gmail
'First get the spam count. if there are no spam mails then exit test
'using GetROProperty to get the innertext of the Spam Link

spamct = browser("title:=Gmail.*").Page("title:=Gmail.*").link("innertext:=Spam.*").GetROProperty("innertext")

'Checking whether spam mails are there or not

If spamct = "Spam" Then
Print "No spam Mails"

'Since there are no spam mail you can exit Test or Exit Action. Based on users decision

ExitTest

'If spam mails are present then we will enter the else part

Else

'we will take the innertext of Spam link and remove all the unnecessary characters and print only the spam count.

spamcount = Replace(spamct, "spam", "") 'replacing the spam word with space
spamcount = Trim(spamcount)
spamcount = Replace(spamcount, "(","")
spamcount = Replace(spamcount, ")","")

'Printing the number of spam mails to the user

print "You have "&spamcount& " unread spam mails and all the available spam mails will be deleted forever"


'clicking on the spam link

Browser("title:=Gmail.*").Page("title:=Gmail.*").sync
Browser("title:=Gmail.*").Page("title:=Gmail.*").link("innertext:=Spam.*").Click

'Creating a description object for check boxes

Set abc_obj = Description.Create
abc_obj("micclass").Value = "WebCheckBox"

'Getting the childobjects i.e Checkboxes

Set browser_checkbox = Browser("title:=Gmail.*").Page("title:=Gmail.*").childobjects(abc_obj)

'using a for loop to set the check boxes to on position i.e selecting them

For i = 0 to browser_checkbox.Count - 1
browser_checkbox(i).Set "ON"
Next

'Clicking on the delete forever button to delete the spam mails

Browser("title:=Gmail.*").Page("title:=Gmail.*").webElement("innertext:=Delete forever","index:=*.*").Click

'using windows script host environment to make sure that the delete forever button is clicked

Set wsh = CreateObject("wscript.Shell")
wsh.sendkeys ("{Enter}")

End If

Description Object in QTP (Description. Create)

We will look at Description Objects (Description. Create in QTP) which is very important in Descriptive programming in QTP. In Descriptive programming we can create object with description being a single property or multiple properties. We actually put a collection of properties for an object. We can create and empty object and place all the required properties in it. This object can be used instead of the actual object.


We will see how to create a Description Object

Set Desc = Description.Create

We are actually using a variable called Desc and add properties to the variable using the Description.Create method. The variable Desc should follow a Set statement and the variable Des is an object reference.

Let us look at the Flight Reservation Application and create some Description objects for logging in to the Flight Reservation Application.


'script to login flight reservation using dynamic descriptive programming

Set dialog_login = Description.create
dialog_login("text").value ="Login"

Set edit_agentname = Description.Create
edit_agentname("attached text").value = "Agent Name:"

Set edit_password = Description.Create
edit_password("attached text").value = "Password:"

Set button_ok = Description.Create
button_ok("text").value ="OK"

Dialog(dialog_login).Activate
Dialog(dialog_login).WinEdit(edit_agentname).Set "Ravi"
Dialog(dialog_login).WinEdit(edit_password).Set "mercury"
Dialog(dialog_login).WinButton(button_ok).Click

In the above code we are actually using the properties and values and creating the objects and using them instead of the actual objects. This kind of method is very easy and maintainable because there is always a scope of adding new properties and values to the Description objects.

The other way to login in to the Flight Reservation Application is by simply putting in the properties and values in the script it self instead of creating description Objects. Instead of learning the objects into the object repository we use the associated properties and values of the object and directly pass them.

Look at the simple script using descriptive programming.

'Descriptive programming to login to the flight application.

Dialog("text:=Login").Activate
Dialog("text:=Login").WinEdit("attached text:=Agent Name:").Set "Ravi"
Dialog("text:=Login").WinEdit("attached text:=Password:").Set "mercury"
Dialog("text:=Login").WinButton("text:=OK").Click

Write a script to delete the mails in the Trash Folder in Gmail Account?

We can write a script to delete all the trash mails in the Gmail Account. First we need to Click the Trash link then click the all link in the trash mail page so that all the available mails in the table are checked and then we need to click the Delete Forever button. I have faced a problem when clicking on the All Link because when the All link is clicked it is actually selecting all the mails in the Inbox because the objects used like Select: All, None, Read, Unread, Starred, Unstarred are being used the same. So I faced a little problem but we can solve that by using object repository for that particular line of code.


If the below script is unable to run then use the other script given below and also learn the objects into the repository specially the Trash Link and the All Link in Gmail. Please look at the Object Repository Image below.

Please note that you need to be logged in to the Gmail Account to successfully run the below scripts.

First Method to delete the trash mails from Gmail Account:

Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("text:=Trash", "class:=n.*").Click
Browser("title:=Gmail - Trash.*").Page("title:=Gmail - Trash.*").Sync
If Browser("title:=Gmail - Trash.*").Page("title:=Gmail - Trash.*").WebElement("innertext:=Empty Trash.*", "html id:=:.*").Exist(1) Then
Browser("title:=Gmail - Trash.*").Page("title:=Gmail - Trash.*").WebElement("innertext:=All", "Index:=*.*").Click
Wait 2
Browser("title:=Gmail - Trash.*").Page("title:=Gmail - Trash.*").WebElement("innertext:=Delete forever","index:=*.*").Click
Else
Print "You are not in proper page"
End If
Set wsh = CreateObject("WScript.Shell")
wsh.SendKeys ("{ENTER}")

If the above script does not work then you need to add objects to the repository and then use this script. We use Windows Script Host because we need to explicitly tell QTP to Click the Delete Forever Button which otherwise some times does not work so in order to resolve this issue we need to create a variable to interact with the Windows Script Host Library. We are also using the Reporter.ReportEvent method to return a pass or fail to the test result whether the messages are deleted or not.

Second Method to delete the trash mails from Gmail Account:

Browser("Gmail").Page("Gmail").Frame("frame").Link("Trash").Click
If Browser("Gmail").Page("Gmail").Frame("frame").Webtable("No conversations in the").Exist (1) Then
Reporter.ReportEvent micPass, "No messages", "There are no messages to be deleted"
Else
Browser("Gmail").Page("Gmail").Frame("frame").WebElement("All").Click
Browser("Gmail").Page("Gmail").Frame("frame").WebElement("Delete forever").Click
Set wsh = CreateObject("wscript.shell")
wsh.sendkeys ("{Enter}")
Reporter.ReportEvent micPass, "Deleted", "All the selected messages are deleted"
End If
The Object repository should learn these objects from the Application in order to run the above script.


Write a Script in QTP to count the no of buzz messages in a Gmail Account.

We will need to use the GetROProperty method to get the count of the buzz messages in the Gmail Account for a user and this number is dynamic so we use the GetRoProperty method and get the innertext value. We will use the GetROProperty (Get Run Time Object Property) to get the count of the Buzz Messages ex Buzz (25) and then replace Buzz, (,) with a null and then print only the number to the user.


'You need to be logged into the Gmail account
Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Buzz.*","class:=n.*").Click
'To get the innertext of Buzz link
buzzcount = Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Buzz.*","class:=n.*").GetROProperty("innertext")
If buzzcount = "Buzz" Then
Print "No Buzz Messages"
ExitAction
Else
buzzct = Replace(buzzcount, "Buzz","")
buzzct = Rtrim(ltrim(buzzct))
buzzct = Replace(buzzct, "(","")
buzzct = Replace(buzzct,")","")
Print "You have "&buzzct& " Buzz Messages."
End If

Write a Script in QTP to count the unread emails of a gmail account.

In order to count the unread emails of a gmail account you need to be logged into the Gmail account and then run this script which will count all the unread email and display the no of unread emails. We will use the GetROProperty (Get Run Time Object Property) to get the no of unread emails ex Inbox (25) and then replace Inbox, (, ) with a null and then print only the number.


The reason for us to use the GetROProperty on the Inbox Link is that the count of unread mails is dynamic and so we need to get the innertext and print the unread emails. So no matter you run any number of times you will get the exact number of unread emails in gmail account. If no unread emails are there then it will print a message saying " No Unread Emails" else it will print "You have xxx unread emails in your inbox"

'You need to be logged into the Gmail account
Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Inbox.*").Click
Browser("title:=Gmail.*").Page("title:=Gmail.*").Sync

'To get the innertext of inbox link
inboxcount = Browser("title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Inbox.*").getroproperty("innertext")
If inboxcount = "Inbox" Then
Print "No Unread Emails."
ExitAction
Else
emailcount = replace(inboxcount, "Inbox","") 'replaces inbox with space
emailcount = Rtrim(ltrim(emailcount)) 'removes all the spaces
emailcount = replace(emailcount, "(","")
emailcount = replace(emailcount, ")","")
Print "You have "&emailcount& " unread emails in your inbox."
End If

Write a Script to Login in to Gmail Account using QTP?

We will write a script to login to a Gmail Account. This QTP Script to log into Gmail Account is a Generic one. There is no need for us to have Object Repository since I am using Descriptive Programming. Where we use the properties and the values to identify the run time object in the Application under test.



We will write a descriptive program to login to Gmail Account. What I am doing is that each of the script contains a line of code to launch Gmail Application and then log into the application

To launch the Gmail application we need to use QTP reserved object like Systemutil or can interact with the Internet Explorer library and launch gmail. After launching the Gmail Application we have the script to login to the account by passing username and password. We will be printing the result at each step to see how the application is behaving

Systemutil.Run "http://www.gmail.com"

Or

'Launching Internet Explorer and Opening Gmail Application
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "http://www.gmail.com"

'We will use the sync method to wait till Gmail opens
Browser("Title:=Gmail.*").Page("title:=Gmail.*").Sync

'Script to set username and password to login
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Email").Set "xxxxxx"
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=Passwd").Set "yyyyyy"
Browser("Title:=Gmail.*").Page("title:=Gmail.*").WebButton("name:=Sign in").click
Browser("Title:=Gmail.*").Page("title:=Gmail.*").Sync
If Browser("Title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Sign out", "html id:=:.*").Exist(1) Then

'Print a Pass message for the user if logged in
Print "User " &Username& " is successfully Logged in"
Else If not Browser("Title:=Gmail.*").Page("title:=Gmail.*").Link("innertext:=Sign out", "html id:=:.*").Exist(1) Then

'Print a Fail message for the user if not able to log in and terminate the action
Print "User " &Username& " is not able to Login in"
Print "The Test has been terminated"
ExitAction
End If
End If

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 Objects in QTP are created to resolve the object recognition problems in QTP. When an area of an application is not recognized by QTP we use the Virtual Object Wizard to 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 the Virtual Object Manager. After we have learned an object as a Virtual Object we can record on that object successfully. You can create a Virtual Object by navigating to Tools, Virtual Objects, New Virtual Object.

Points to Note:

1. We cannot use object spy on a Virtual Object.
2. We can only record on Virtual Objects.
3. Scroll Bars and Labels cannot be treated as Virtual Objects.

In order to disable the Virtual Objects Navigate to Tools, Options, General, Check the check box for "Disable Recognition of Virtual Objects While Recording"

When Object recognition Problem occurs in QTP during playback on the Application Under test there are ways to handle this Object Recognition Problem. It depends solely on the user as to what they want to use.

The different ways to handle Object Recognition Problem are:

1. By Creating Virtual Objects.
2. Using Low Level Recording.
3. Using Analog Recording.

Creating a MS Word Document using QTP 9.2

Creating a MS Word Document in QTP is not difficult but is very easy and one needs to know how to use the Word Application in QTP.

It is very easy to create a MS Word Document using QTP. There is no need to invoke the MS Word application in QTP but we require to use the Word Library by using the CreateObject method. If you have word on Excel Application in QTP then it is more or less similar working with Word Library. I will show a sample script to create a word document and also add some text to the word Document.


Script to create a Word Document in QTP

Set wordapp = CreateObject("Word.Application")
wordapp.visible = True
wordapp.documents.Add
wordapp.Selection.TypeText "This is a sample document"
wordapp.ActiveDocument.SaveAs "E:\testdoc.doc"
wordapp.Quit
Set wordapp = Nothing

We are using Wordapp.Visible = true because we want the application to be visible for the user while the text is being written to the Word Document. TypeText property is used to write the text in the word document. In order to save the document we use ActiveDocument menthod because in case if there are other word document already opened then the active document will be saved.

Recovery Settings in QTP

Recovery scenario comes into picture when you want to handle some exception in the test by creating a Recovery scenario. Now to add this recovery scenario to a test we need to associate it in the test Settings.


You need to navigate to File > Setting > Test Settings >Resources.


You can add the recovery scenario file .qrs by clicking the + button and checking the check button in the list pane for a particular recovery file and also can activate the recovery scenario for which you want like Never, On every Step or On error.

You can also edit the recovery scenario by clicking the edit button.

Environment Settings in QTP

User Defined Environment Variables in QTP


Environment Variables in QTP are the utility objects of QTP which enables us to work with Environment Variables. In the Test Settings we can add user defined Environment Variables for a particular test or can also load an environment XML file to a test.


You need to Navigate to File > Settings > Test Settings > Environment

User defined variables are of two types Internal and External. Internal Environment variables can be modified or deleted while External Environment variables are Read only.


In this setting we can add environment variables by clicking the + button which pops up a dialog box where in you can enter the name of the variable and the value of the variable and will be displayed in Black color and the type would be displayed as Internal and you have full control over these kinds of variables. You can modify or delete these variables.

You can create an external XML file of all the user defined environment variables to an XML file listed in the pane by clicking the export button.

In order to load environment variables from an external XML file you need to check the check button of Load variables and values from external file and click the browse button of the File Text Box and select the XML file from the desired location. All the environment variable will be listed and will be in Blue color and are read only.

Built in EnvironmentVariables Settings in QTP

Environment Variables in QTP are the utility objects of QTP which enables us to work with Environment Variables. Here in this tab you have two settings one is Built in and user Defined.


You need to Navigate to File > Settings > Test Settings > Environment

Built in Environment Variables:

Built in environment settings in QTP is where you will be shown a list of all built in environment variables of QTP and their description. These are read only.

Resources Settings in QTP

Associating Function Libraries to a QTP Test is very important as it is associated from an external location and since we use frame work each of the test script is broken down into different functions and there should be a way to associate them to a test. The Resource Tab in Test Settings helps you to do this.


You need to navigate to File > Settings > Test Settings > Resources.

Here we will look at the various options available for user to set under resources in QTP while running a test.


Here you can associate function libraries to QTP test by clicking the + sign and select the location from where you want to add. In order to delete a library file select that file from the list and click the Delete button i.e X button. You can arrange the function library files by using the up and Down key.

It also provides a means to check the syntax of the files associated by clicking the Check syntax Button.

There is a means to associate a data table from other location i.e Excel sheet for passing values as parameters to the test from default location or from any other location.

Run Settings in QTP

Test Settings in QTP is very vital as it provides a lot of settings for a test and allows you to control the way QTP should run.


You can customize the settings of QTP for each test by navigating to File > Settings > Test Settings > Run.

Here we will look at the various options available for user customize Run Settings in QTP while running a test.


Run one iteration only: The test will run only for one time.

Run on all rows: The test will run on all rows

When error occurs during run session combo has these options

1. Pop up message box
2. Proceed to next action iteration
3. Stop Run
4. Proceed to next step

Check box items are:

Object synchronization time out text box with 20 sec as default.

Disable smart identification during run session

/* Tynt Insight tracker ----------------------------------------------- */