Rehearsal of QTP in 1 Hr: Interview Questions 151 – 160
While appearing in an interview for a position on HP QuickTest Professional, do a quick rehearsal of your knowledge on this tool.
Here is a collection of 180 short questions, QTP Managers commonly use while interviewing new aspirants for their organization.
The entire rehearsal of these questions can take less than an hour.
Set of Ten Questions
Q. 151: What does a Recovery Scenario consists of?
Trigger: Trigger is nothing but the cause for initiating the recovery scenario. It could be any popup window, any test error, particular state of an object or any application error.
Action: Action defines what needs to be done if
scenario has been triggered. It can consist of a mouse / keyboard event, close application, call a recovery function defined in library file or restart windows. You can have a series of all the specified actions.
Post-recovery operation: Basically defined what need to be done after the recovery action has been taken. It could be to repeat the step, move to next step etc….
<<<<<< =================== >>>>>>
Q. 152: When do we use a Recovery Scenario and when to use “on error resume next”?
Recovery scenarios are used when you cannot predict at what step the error can occur or when you know that error won’t occur in your
QTP script but could occur in the world outside QTP, again the example would be “out of paper”, as this error is caused by printer device driver.
“On error resume next” should be used when you know if an error is expected and don�t want to raise it, you may want to have different actions depending upon the error that occurred.
Use err.number & err.description to get more details about the error.
<<<<<< =================== >>>>>>
Q. 153: What are Library Files or VBScript Files? And How do we associate a library file with a test?
Library files are files containing normal VBScript code.
The file can contain function, sub procedure, classes etc…. You can also use executefile function to include a file at run-time also.
To associate a library file with your script go to Test->Settings… and add your library file to resources tab.
<<<<<< =================== >>>>>>
Q. 154: When to associate a library file with a test and when to use execute file?
When we associate a library file with the test, then all the functions within that library are available to all the actions present in the test.
But when we use Executefile function to load a library file, then the function are available in the action that called executefile.
By associating a library to a test we share variables across action (global variables basically), using association also makes it possible to execute code as soon as the script runs because while loading the script on startup QTP executes all the code on the global scope.
We can use executefile in a library file associated with the test to load dynamic files and they will be available to all the actions in the test.
<<<<<< =================== >>>>>>
Q. 155: What is the difference between Test Objects and Run Time Objects?
Test objects are basic and generic objects that QTP recognize.
Run time object means the actual object to which a test object maps.
<<<<<< =================== >>>>>>
Q. 156: Can I change properties of a test object?
Yes. You can use SetTOProperty to change the test object properties.
It is recommended that you switch off the Smart Identification for the object on which you use SetTOProperty function.
<<<<<< =================== >>>>>>
Q. 157: Can I change properties of a run time object?
No (but Yes as well).
You can use GetROProperty(“outerText”) to get the outerText of a object but there is no function like SetROProperty to change this property.
But you can use WebElement().object.outerText=”Something” to change the property.
<<<<<< =================== >>>>>>
Q. 158: What is the difference between an Action and a function?
Action is a thing specific to QTP while functions are a generic thing, which is a feature of VB Scripting. Action can have a object repository associated with it while a function can’t.
A function is just lines of code with some/none parameters and a single return value while an action can have more than one output parameters.
<<<<<< =================== >>>>>>
Q. 159: Where do we use function or action?
The answer to this question depends on the scenario.
If you want to use the OR feature then you have to go for Action only.
If the functionality is not about any automation script i.e. a function like getting a string between to specific characters, now this is something not specific to QTP and can be done on pure VB Script, so this should be done in a function and not an action.
Code specific to QTP can also be put into function using Descriptive Programming.
Decision of using function / action depends on what any one would be comfortable using in a given situation.
<<<<<< =================== >>>>>>
Q. 160: Which object is used to read from text file?
Scripting.FileSystemObject”
Continue to Next Set of QTP Rehearsal Questions 161 – 170
An expert on R&D, Online Training and Publishing. He is M.Tech. (Honours) and is a part of the STG team since inception.