QTP Interview Questions and Answers
Question - 91 : - What is “settoproperty” and when to use it in UFT?
Answer - 91 : -
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.
Question - 92 : - In QTP how you can remove the spaces from string?
Answer - 92 : -
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”
Question - 93 : - In QTP how you can get the last character from a string?
Answer - 93 : -
Code to get the last character of a string in QTP
print right( “junior,1) ‘ à Output will be “r”
Question - 94 : - How to add synchronisation points in QTP?
Answer - 94 : -
There are 4 ways through which we can add synchronisation points in QTP
a) Wait statement : This statement will pause the execution for x seconds until object comes up
b) Wait property : This method will wait until property of object takes particular value
c) Exist statement : This statement will wait until object becomes available
d) Sync method: The code will wait until browser page is completely loaded. For web application testing this method is used.
Question - 95 : - In QTP explain what is crypt object
Answer - 95 : -
Crypt object in QTP is used to encrypt a strings.
Syntax
Crypt.Encrypt(“Name”)
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
Question - 96 : - Mention what is the difference between Excecute file and loadfunction library?
Answer - 96 : -
In execute file, we can’t debug the statements. With loadfunction library, statements can be debug and can also load multiple library files.
Question - 97 : - Explain how you can find length of array in QTP?
Answer - 97 : -
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
Question - 98 : - Mention what are the different types of recording modes in QTP? Which will be used when?
Answer - 98 : -
QTP supports 3 types of recording modes
a) 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.
b) 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.
c) Analog mode: This mode is useful for the operation such as recording signature, drawing a picture, drag and drop operation.
Question - 99 : - In what ways you can call from one action to another action?
Answer - 99 : -
There are two ways you can call from one action to another action
a) Call to copy of action: In this, the script and data-table, action object repository will be copied to the destination Test Script
b) Call to existing Action: In this, script data-table and object repository are not copied instead a call reference would be made to the action in the source script
Question - 100 : - What is Optional step in QTP? How you can add optional step in QTP?
Answer - 100 : -
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.