Below are some useful tips to prepare for HP QTP interview, followed by the most common QTP/UFT interview questions and answers.
If there is any new QTP interview question that have been asked to you, kindly post it in the the comment section.
Ans:
QTP supports the following environments
Ans:
QTP Supports 2 types of Object Repository
Per-Action Object Repository is used by default. The extension for Per-Action repository is “.mtr” .
Shared Object Repository is preferable while dealing with dynamic objects which are called in multiple tests. The extension is “.tsr”
Ans:
Yes. You can call 4 or even more scripts in your tests.For this, first you will need to make the Actions in the corresponding scripts re-usable.Then from the destination script you can make calls to these re-usable actions.
Ans:
Action split is to divide an existing action into two parts.The purpose is to divide actions based on their functionality to improve code re-use.
Ans:
Foremost you will select Java Add – In and launch QTP. Next step record operations on the Java Tree. If you face an issue while recording, you can select Tools > Object Identification > Java, tree object and make changes in mandatory and assistive properties to enable identification.
Tip: You can base you answer on similar lines for any other object of any environment. For example : If the question is how will check SAP checkbox , You say , first I will select SAP Add in … and so on.
Ans:
QTP identifies any GUI Object based on its corresponding properties. While recording, QTP will identify and store peculiar properties (as defined in the Object Identification settings) in the object repository of the GUI object . At run-time, QTP will compare the stored property values with the on-screen properties, to uniquely identify the GUI object.
Ans:
QTP supports 3 types of recording modes
Normal Mode: It is the default recording mode and takes full advantage of QTP’s Test Object Model. It recognizes objects regardless of their position on -screen. This is the preferred mode of recoding and is used for most of the automation activities.
Low-level recording mode: This mode records the exact x,y co-ordinates of your mouse operations. It is helpful in testing hashmaps. It is useful for recording objects not identified by normal mode of QTP.
Ans:
We can call an action in 2 ways
Ans:
Your application may contain objects that behave like standard objects but are not recognized by QTP. You can define these objects as virtual objects and map them to standard classes, such as a button or a check box. QTP emulates the user’s action on the virtual object during the run session. In the test results, the virtual object is displayed as though it is a standard class object.
For example, suppose you want to record a test on a Web page containing a bitmap that the user clicks. The bitmap contains several different hyperlink areas, and each area opens a different destination page. When you record a test, the Web site matches the coordinates of the click on the bitmap and opens the destination page.
To enable QTP to click at the required coordinates during a run session, you can define a virtual object for an area of the bitmap, which includes those coordinates, and map it to the button class. When you run a test, QTP clicks the bitmap in the area defined as a virtual object so that the Web site opens the correct destination page.
Ans:
You will need to create separate Actions which take care of different OS and Browsers
Analog mode: This mode records exact mouse and keyboard “movements” you perform in relation to the screen / application window. This mode is useful for the operation such as drawing a picture, recording signature., drag and drop operations.
Cross Platform Testing:
Using the Built in Environment Variable you can dig up the OS information.
Eg. Platform = Environment(“OS”). Then based on the Platform you need to call the actions which you recorded on that particular platform.
Cross Browser Testing:
Using this code Eg. Browser(“Core Values”).GetROProperty(“version”) you can extract the Browser and its correspondin version. Ex: Internet Explorer 6 or Netscape 5. Based on this value you call the actions which are relevant to that browser.
Using the Built in Environment Variable you can dig up the OS information.
Eg. Platform = Environment(“OS”). Then based on the Platform you need to call the actions which you recorded on that particular platform.
Cross Browser Testing:
Using this code Eg. Browser(“Core Values”).GetROProperty(“version”) you can extract the Browser and its correspondin version. Ex: Internet Explorer 6 or Netscape 5. Based on this value you call the actions which are relevant to that browser.
Ans:
Logical name is a name given by QTP while creating an object in the repository to uniquely identify it from other objects in the application. This name would be used by the QTP to map the object name in script with its corresponding description in the object repository.
Ans:
Typically ,an object and its properties must be recorded in the Object Repository to enable QTP to perform action s on it.
Using descriptive programming , you do not store the object and its property values in the Object repository but mention the property value pair directly in the script.
The idea behind descriptive programming is not bypass the object repository but help recogonize dynamic objects.
Ans:
You can use the name property
ex: Browser(“name:=”xxx””).page(“name:=”xxxx””)…..
OR
We can also use the property “micClass”.
ex: Browser(“micClass:=browser”).page(“micClass:=page”)….
Ans:
Yes .you can record remote application provided you are accessing application through the local browser not via remoter like citrix.
If you are still unable to record it is advisable install QTP and application, on the same machine
Ans:
Creates and returns a reference to an Automation object
SYNTAX: CreateObject(servername.typename [, location])
Arguments
servername: Required. The name of the application providing the object.
typename : Required. The type or class of the object to create.
location : Optional. The name of the network server where the object is to be created.
Example : Set IE = CreateObject(“InternetExplorer.Application”)
Ans:
Yes .We can switch. Go to Test—>Settings—>Resources. Here you have an option to choose repositories.
Ans:
Object Spy helps in determining the run & test time object properties & methods of the application under test.
You can access object spy directly from the toolbar or from the Object Repository Dialog Box.
Ans:
Consider the following –
Hence mandatory and assistive properties are used.
Ans:
Code file extension is script.mts
Ans:
QTP Automation Object model deals with Automation of QTP itself. Almost all configuration and functionality provided by QTP is represented by QTP’s Automation Object Model . Almost all dialog boxes in QTP have a corresponding automation object which can set or retrieved using the corresponding properties or methods in the Automation Object Model.QTP Automation Objects can be used along with standard VB programming elements like iterative loops or conditional statements to help you design a script of choice.
Ans:
Text Output values enable you to capture text appearing on the application under test during run-time.
If parameterized, text output values will capture values appearing in each iteration which would be stored in the run-time data table for further analysis.
Ans:
Step Generator enables use to Add Test Steps in your script. Using step generator you can add steps to your script without actually recording it.
Ans:
You can use ordinal identifiers like index along with a little descriptive programming for object recognition.
Ans:
Test Fusion Report , displays all aspects of a test run and is organized in a Tree format.
It gives details of each step executed for all iterations.
It also gives Run-time data table, Screen shots and movie of the test run if opted.
Ans:
In QTP Exceptional handling is done by using
In Recovery scenario you have to define.
At Script Level you can use the On Error Resume Next and On Error Go to 0 statement.
Ans:
Environment variables in QTP are of three types:
Built-in (Read only)
User-defined Internal (Read only)
User-defined External (Read/Write)
You Set the Environment Variable using the following syntax
Environment.Value( “name”) = “example”
You can Retrieve the Environment Variable using following syntax
Environment.Value(“name”) — This will retrun name as example
Environment.Value(“OS”) — This will return your system OS
Ans:
Image checkpoint does do a pixel to pixel comparison but instead compare image properties like alt text , destination url etc.
Ans:
Actions have their own Object Repository & Data Table. Actions help make your Test modular and increase reuse. Example: You can divide your script into Actions based on functionality like Login, Logout etc.
Functions is a VB Script programming concept and do not have their own Object Repository or Data Table. Functions help in re-use of your code. Ex: You can create a Function in your script to concatenate two strings.
Ans:
Keyword View is an icon based view which shows test steps in tabular format. It also automatically generates documentation for the test steps.
Expert View gives the corresponding VB Script statement for every test step in the Keyword view.
Ans:
Quick Test testing process consists of 6 main phases:
Ans:
The types of Automation Frameworks are –
Ans:
You can use the Page Checkpoint which gives a count of valid/invalid links on a page.
Ans:
Data like parameterized output , checkpoint values , output values are stored in the Run-time Table. It is an xls file which is stored in the Test Results Folder. It can also be accessed in the Test Fusion Report.
Ans:
Check point is a verification point that compares a current value for a specified property with the expected value for that property. Based on this comparison, it will generate a PASS or FAIL status.
An output value is a value captured during the test run and can be stored in a specified location like the Datable or even a variable. Unlike Checkpoints, no PASS/FAIL status is generated.
Ans:
To connect to the database you must know
You can code the database connectivity command directly or you can use the SQL Query tool provided by QTP.
Ans:
You can use the Batch testing tool to run multiple scripts. Once the scripts are added in the tool , it will automatically open the scripts and start executing them one after the other.
Ans:
As of QTP version 10
Ans:
A step when declared optional is not mandatory to be executed. If the corresponding GUI object is present, QTP performs the operation on it. If the GUI object is not present, QTP bypasses the optional step and proceeds to execute the next step.
Ans:
Reporter.Reportvent is standard method provided by QTP to send custom messages to the test results window.
Syntax
Reporter.ReportEvent EventStatus, ReportStepName, Details [, ImageFilePath]
where
EventStatus = 0 or micPass
1 or micFail
2 or micDone
3 or micWarning
Results can assume any status like Pass , Fail , Warning etc. You can also send screenshot to the test results window.
Ans:
You declare using a DIM keyword. You assign value to the variable using the SET keyword.
Ex.
Dim temp ‘Will declare the temp variable
Set temp = 20 ‘ Will assign a value 20 to temp.
Ans:
GetRoProperty is a standard method provided by QTP to fetch property values of a run -time object.
Ans:
Typically, if even one of the on-screen object property does not match the recorded object property. The test fails.
In smart identification, QTP does not give an error if the property values do not match, but uses Base filter and Optional Filter properties to uniquely identify an object. In Smart identification, if a property value does not match the script does not fail but it proceeds ahead to compare the next property. Smart identification can be enabled in Object Identification Dialog box.
Ans:
We can make use of the “Generate Script” function available in Object Identification, Test Settings and Tools/Options tab to create a zip of the script at the source computer. These zip files then can be imported into QTP at the destination computer.
Ans:
No. You can work with only single instance of QTP on the same machine. But QTP itself can work on multiple instances of the Application Under Test (AUT). Ex: QTP can handle multiple IE browser windows.
Ans:
DataTable.ImportSheet “..\..\TestData\Input.xls”,1,dtGlobalSheet
DataTable.ExportSheet “..\..\Results\Output.xls”,”Global”
Ans:
SetToProperty changes property of an object stored in the Object Repository. However these changes are not permanent.
Ans:
The standard delay is 60 seconds. This is can be changed in Test Settigns.
Ans:
It is an in-built tool provided by QTP to convert Actions into Business Process Components.
Ans:
The extension is ‘.QFL’
Ans:
The test will iterate only once – global iteration.
Ans:
The example demonstrated here explains how to read registry key in UFT
‘Create a shell object
Set MyShell= CreateObject (“WScript.Shell”)
Read the value of key from the registry
RegValue =MyShell.RegRead (varpathofkey)
‘in above function we have to pass the path of key in registery’.
e.g. HKCU\software\ie\settings
msgbox RegValue
Ans:
There are three ways to get system environment variables in UFT
Use the WSH shell object
Use WMI’s Win32_Environment Class
Read variables from the registry
Set myShell = CreateObject (“WScript.Shell”)
WScript.Echo myShell.ExpandEnvironmentStrings( “%PATHEXT%” )
myShell=Nothing,
The output will be .BAT;.CMD;.VBS;. VBE;. JS;. JSE
Other user variable, like TEMP, overwrite their system counterpart
Set myShell = CreateObject( “WScript.Shell” )
WScript.Echo myShell.ExpandEnvironmentStrings( “TEMP=%TEMP%” )
myShell=Nothing
The output will be TEMP:C:\DOCUME~1\You\LOCALS~1\Temp
Ans:
To send mail from outlook in UFT,
Set Outlook = CreateObject (“Outlook.Application”)
Dim Message ‘As Outlook.MailItem
Set Message = Outlook.CreateItem(olMailItem)
With Message
.Subject = Subject
.HTMLBody = TextBody
.Recipients.Add (aTo)
Const olOriginator = 0
.Send
End With
Ans:
To fetch data from database in UFT, you have to follow the code below
Set db= createobject (“ADODB.Connection”)
db.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\example\vb6\admission_project.mdb;
Persist Security Info= False”
Set rst=createobject(“ADODB.Recordset”)
rst.Open “select*from Course”, db, 3
id=rst. RecordCount
For i=0 to id-1
Print rst.field (0) & rst.fields (1) & rst.fields (2) & rst.fields (3)
rst.Movenext
Next
Ans:
To get ftp files from ftp server, you have to use below code
put– To store single file on server
get– To download single file from ftp server
mget– To download multiple files from server
mput– To store multiple files on server
delete– To delete files on ftp server
MyShell.Run “%comspec% /c FTP -n -s:” & commandstoworkwithftp & ” ” & Site, 0,True
Ans:
To prevent system getting locked, any of the two ways can be used
Create a simple vbs file having code to press numlock key and run that vbs file
Edit one registry key “DisableLockWorkstation =1” to disable locking
Ans:
Descriptive programming includes property name and property value. Whenever UFT is facing difficulty in identifying objects from object repository, and instead the object is directly identified from the script is known as descriptive programming.
Ans:
Ans:
To write data to text file in UFT code is
Content = “example Rocks”
Set Fo = createobject (“Scripting.FilesystemObject”)
Set f = Fo.openTextFile (“c:\myFile.txt”,8,true) ‘ open in write mode
f.Write (contents)
f.Close
Set f = nothing
Ans:
Code to write data to Excel file in UFT is
filepath = “C:\Bugs\Reports.xlsx”
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible= True
Set Wb= objExcel.Workbooks.Open (filepath)
Wb.worksheets(1).Cells(1,1).Value = “example” read value from Excel file
Ans:
TSR means Test Shared Repository, it is created to share object repository.
To create TSR file, follow the steps
Ans:
To connect with QC, UFT provides the option to connect QC directly from UFT GUI.
Following above steps will allow you to connect with QC, later on you can execute the tests from QC itself.
Ans:
In order to ease the process of test automation using UFT, test automation is designed. There are mainly three types of automation frameworks in UFT
Keyword Driven Framework: It is used when multiple functionality needs to be tested.
Data Driven Framework: It is used to test same flow with different test data, test data is given more importance than multiple functionality of application
Hybrid Framework: It is a combination of data driven framework and keyword.
Ans:
Either through object repository or description programming, UFT identifies objects. Descriptive programming is used in following scenarios.
Ans:
Settoproperty stands for set test object property. You can use this property to change the object values at runtime. You can edit the property values during the runtime, but the changes that are made are temporary.
Ans:
We can create an array of dictionary using syntax
Dim ArrayofDictionary(2)
First element of array
Set ArrayofDictionary(0)= createobject(“scripting.dictionary”)
ArrayofDictionary(0).Add “key1”, “temp1”
ArrayofDictionary(0).Add “key2”, “temp2”
Added keys in first dictionary
Second element of array as dictionary
Set ArrayofDictionary(1)= createobject(“scripting.dictionary”)
ArrayofDictionary(1).Add “key1”, “temp1”
ArrayofDictionary(1).Add “key2”, “temp2”
Added keys in second dictionary…..and so on
Ans:
S.NO | Array | Dictionary |
1 | We can have dynamic array | We do not have concept called dynamic Dictionary. |
2 | Before use of array we must set the size of array | We do not need to set the size of dictionary. |
3 | Before adding extra element into dynamic array, We have to use redim statement | We do not need to write any statement to add extra element. We just use add method. |
4 | We do not have any method to release the memory if particular element is not required | We can remove the element that is not required any longer. |
Ans:
Round function in UFT is used to round the decimal For example
Mydecimal = 6.3433333
Roundedvalue= Round(Mydecimal , 3)
Print roundedvalue, it will print 6.343
Ans:
There are three ways which we can find the count of rows in the table in UFT
Ans:
steps will create excel file in UFT,
‘Create a new Microsoft Excel object
Set myExcel = createobject(“excel.application”)
‘To make Excel visible
myExcel.Application.Visible = true
myExcel.Workbooks.Add
MyExcel.worksheets(1).Cells(1,1). Value = “Scenario Id”
MyExcel.worksheets(1).Cells(1,2).Value = “Scenario Name”
MyExcel.worksheets(1).Columns(1).ColumnWidth = 10
MyExcel.worksheets(1).Columns(2).ColumnWidth = 40
MyExcel.worksheets(1).Columns(3).ColumnWidth = 20
MyExcel.worksheets(1).Columns(4).ColumnWidth = 20
MyExcel.SaveAs “c:\guru99.xlsx”
MyExcel.close
objExcel.Quit
blnFlag = False
Ans:
To export data-table to excel, there are two methods.
DataTable.Export (“C:\export.xls”)
DataTable.ExportSheet “C:\mysheet.xls” ( If excel file does not exist, new file is created)
Ans:
To read a value from the cell, we follow 2 step process
We set the row pointer in first step
In second step we define the parameter/column name from the sheet to read
Example:
For this example, we have set the row pointer to 2 in transaction sheet
Datatable.GetSheet(“Transactions”).SetCurrentRow(2)
Now, we have to specify that we want to read a value from the module_name column from the transaction sheet
Print datatable.Value (“Module_Name, “Transactions”)
Ans:
There are 3 loops available in UFT
Do…..Loop : Do Loop will run a block of statements repeatedly
For…..Next : For Next Loop will execute a series of statements until a specific counter value
For……Each : In order to execute a series of statements for each statements for each object in collection “For Each Loop” is used
While….Wend Loop : While Wend Loop is used to execute a series of statements as long as given condition is true
Ans:
There are three types of error that one will face in UFT
There are various ways to handle run time errors
Ans:
Exitaction is used when we want to exit from a particular action, while exititeration is used to exit from a particular action iteration of an action.
Ans:
You can use replace function to remove spaces from string in QTP
Print replace(“ sdsd sd sd s “, “ “,”””)
Output will be sdsdsdsds
Itrim function can be used if only leading spaces from string needs to be removed
Print Itrim(“ sdsd sd s “) à Output will be “sdsd sd s”
You can use rtrim function to remove trailing spaces from string
Print rtrim(“ sdsd sd s ” ) à Output will be “ sdsd sd s”
Ans:
Code to get the last character of a string in QTP
print right( “junior,1) ‘ à Output will be “r”
Ans:
There are 4 ways through which we can add synchronisation points in QTP
Wait statement : This statement will pause the execution for x seconds until object comes up
Wait property : This method will wait until property of object takes particular value
Exist statement : This statement will wait until object becomes available
Sync method: The code will wait until browser page is completely loaded. For web application testing this method is used.
Ans:
Crypt object in QTP is used to encrypt a strings.
Syntax
Crypt.Encrypt(“Guru99”)
Example :
In this example, value in pwd variable is encrypted using the Crypt. Encrypt method.
Then this encrypted value is entered into editbox.
pwd= “myvalue”
pwd = Crypt.Encrypt (pwd)
Browser(“myb”).WinEdit (“pwd”). SetSecure pwd
Ans:
In execute file, we can’t debug the statements. With loadfunction library, statements can be debug and can also load multiple library files.
Ans:
The code to find the length of array in QTP is
print (ubound(arr)+1)
Ubound returns the last index in array- so length of array will be +1. This will be total number of elements in array
Ans:
QTP supports 3 types of recording modes
Normal mode : It is the default recording mode and used for most of the automation activities. Regardless of their position on screen it recognizes objects.
Low level recording mode: It is useful for recording objects not identified by normal mode of QTP. It records the exact x,y coordinates of your mouse operations.
Analog mode: This mode is useful for the operation such as recording signature, drawing a picture, drag and drop operation.
Ans:
There are two ways you can call from one action to another action
Ans:
When running a test, it test fails in opening a dialog box, QTP does not necessarily abort the test run. It bye passes any step designated “optional” and continues running the test. By default QTP automatically marks as optional steps that open certain dialog boxes. In order to set an optional step in the keyword, right click and select “Optional Step”. The icon for optional step would be added in next step. In the expert view to add optional step, add optional step to the beginning of the VBScript statement.
Ans:
Array can be defined in 3 ways in QTP
Fixed size array in QTP
Dim A (10) – single dimension
Dim MyTable (5,10) – multi-dimension
Dynamic array-size not fixed
Dim MyArray()ReDim MyArray(25)
Using Array Function in QTP
A= Array (10, 20,30)
B= A(2) ‘ B is now 30
Ans:
Content = “example”
Set Fo = createobject(“Scripting.FilesystemObject”)
Set f =Fo.openTextFile(“c:\abc.txt”, 8,true)
f.Write (contents)
f.Close
Set f= nothing
Ans:
To specify that all variable must be declared before use in QTP, ‘Option Explicit’ keyword is used.
Ans:
You must use “Exit For” statement to exit “for loop” in QTP. “Exit For” statement will get the control out of the “for loop”
For count= 1 to 3
TempNum= mid(Tempstr,count,1)
If isnumeric(TempNum) Then
LenghtNum = LengthNum & TempNum
Else
Exit For
End If
Next
GetStrLenNumber = LengthNum
Ans:
Size of an array in QTP will be found by using the following code Print (ubound(arr)+1)
Ubound returns the last index in array- so size of array will be +1
Ans:
qrs means “Quicktest Recovery Scenario”. By using recovery scenario manager we can handle exceptions in test execution.In QTP using recovery scenario manager we can handle exceptions in test execution. In QTP when you create a recovery scenario, you must save it in .qrs file. qrs file may have any number of scenarios defined in it.
Ans:
“Action 0” is created by default when you create a new test in QTP along with action 1. To determine the sequence in which we call other actions 1,2,3 etc. action 0 is used.
Ans:
To replace part of string in QTP we will use the code as shown below Example,
Str = (example)
Suppose if you want to replace “99” with “88” then the code will
print replace(str,“99”, “88”) output will be “example”
Ans:
Various types of automation frameworks available in QTP are
Ans:
‘Object Spy’ is a feature in QTP by using which you can view both the test and run time object properties and methods.
Ans:
“GetROProperty” is an in built method used to retrieve runtime value of an object property.
To use GetRoProperty it involves four steps
Ans:
To find out the absolute value of a number a built in function in QTP is available
Example- a= -1
Print abs(a) ‘output will be 1
This code will find the absolute value of a number
Ans:
To check whether if parameter exists in data table we will use the code
on error resume next
val=DataTable(“ParamName”, dtGlobalSheet)
if err.number<>0 then
‘Parameter does not exist’
else
‘Parameter exists
end if
Ans:
In keyword driven automation framework, the focus is mainly on keywords/functions and not the test data. It means the complete focus is on creating functions which maps the functionality of the application.
Ans:
Xpath can be used to identify only web objects. We can use the following code to identify objects.
Set oPage=Browser(“myGoogle”).Page(“myGoogle”)
oPage.WebEdit(“xpath:=//INPUT[@name=‘nameofeditbox’]”).Set “search term”
‘Enter value in google edit box
Here you can get 3 Questions bonus 🙂
Ans:
To delete excel file in QTP,
Set fo = createobject(“Scripting.filesystemobject”)
fo.deletefile(“C:\xyz.xlsx”)
Set fo=nothing
Ans:
Bitmap checkpoints are affected by screen resolution and image size.
Ans:
World Wide Web Consortium (W3C) came up with some instructions and guidelines for Web-based technology and information systems to make it easy for the disabled to access the web. For example the standards make it mandatory to have an ‘alt text’ for an image. So a blind person who is accessing the website, will use text – to -speech converters and atleast understand what the image is about if not see it. All these standards are checked by Accessibility Checkpoints.
In this software era doesn't matter you are working on php,java or .net, everywhere there…
Here we have mentioned most frequently asked IT Fresher Interview Questions and Answers specially for…
Here we have mentioned most frequently asked Github Interview Questions and Answers specially for freshers…
In this software era doesn't matter you are working on php,java or .net, everywhere there is demand frontend software (such…
Here we have mentioned most frequently asked IT Fresher Interview Questions and Answers specially for freshers and experienced. 1. What…
Here we have mentioned most frequently asked Github Interview Questions and Answers specially for freshers and experienced. 1. What is…
Here we have mentioned most frequently asked HTML5 Interview Questions and Answers specially for freshers and experienced. 1. What is…
Here we have mentioned most frequently asked Geography Interview Questions and Answers specially for freshers and experienced. 1. What is…
Here we have mentioned most frequently asked JSP Interview Questions and Answers specially for freshers and experienced. 1. Explain JSP…
This website uses cookies.