QTP Interview Questions and Answers
Question - 101 : - How to define array in QTP?
Answer - 101 : -
Array can be defined in 3 ways in QTP
a) Fixed size array in QTP
Dim A (10) – single dimension
Dim MyTable (5,10) – multi-dimension
b) Dynamic array-size not fixed
Dim MyArray()ReDim MyArray(25)
c) Using Array Function in QTP
A= Array (10, 20,30)
B= A(2) ‘ B is now 30
Question - 102 : - When ‘option explicit’ keyword is used in QTP?
Answer - 102 : -
To specify that all variable must be declared before use in QTP, ‘Option Explicit’ keyword is used.
Question - 103 : - In QTP how you can exit for loop?
Answer - 103 : -
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
Question - 104 : - How to find array size in QTP?
Answer - 104 : -
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
Question - 105 : - In QTP, explain what is qrs file?
Answer - 105 : -
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.
Question - 106 : - What is the significance of “action 0” in QTP?
Answer - 106 : -
“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.
Question - 107 : - What are the various automation frameworks available in QTP?
Answer - 107 : -
Various types of automation frameworks available in QTP are
a) Linear Scripting
b) The Test Library Architecture Framework
c) The Data Driven Testing Framework
d) The Keyword Driven or Table Driven Testing Framework
e) The Hybrid Test Automation Framework
Question - 108 : - What is ‘Object Spy’ and what is the function of object spy in QTP?
Answer - 108 : -
‘Object Spy’ is a feature in QTP by using which you can view both the test and run time object properties and methods.
Question - 109 : - What is “GetROProperty” and what are the steps involved in using GetROProperty?
Answer - 109 : -
“GetROProperty” is an in built method used to retrieve runtime value of an object property.
To use GetRoProperty it involves four steps
a) Record the object on which you want to use the GetROProperty in Object Repository
b) Identify the run time property for the recorded object which could be used
c) To retrieve the identified run time property and store the value in a variable
d) Use this value for further deductions
Question - 110 : - Explain how you can find the absolute value of the number in QTP?
Answer - 110 : -
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