Tuesday, February 5, 2013

QTP- Some Basic Questions


Type of Objects available in QTP

There are 4 types of Objects available in QTP.

1) Run-time Objects- it present under Application under Test (AUT) is called run time object. State can be Enable, disable,focused
2) Test Objects-Reference of run time object is called Test object
3) Utility Objects
4) Automation / User Defined Objects- user defined objects used to work with files, drives, folder etc. example FileSystemObject, ExcelObject, Database connection object etc

Utility Objects

These are QTP reserved objects, used for Testing and Result reporting.
Example:

a) SystemUtil
b) Reporter
c) DataTable
d) Services
e) environment etc...

About Object, Property and value

Object: It is something which has structure and properties
Property: an attribute of an Object.
Value: Value of the Property

About Statement, Action and Test in QTP

Statement: an Instruction or a minimal executable unit
Action: Set of Statements
Test: One or more Actions

How Load repository files During run-time?

We can Load Object Repositories during run-time using an Utility object called "RepositoriesCollection"
Syntax:
RepositoriesCollection.Add "path of the Repository file"

Example:
RepositoriesCollection.Add "D:\ORsample.tsr"

Monday, January 14, 2013

QTP 11- File Setting Tab

In QTP11, File setting tab having 12 options.
  1. Properties - from where generate script option available
  2. Run - from where script run option can be change - datatable iteration- 1 iteration, all iteration, all row etc
  3. Resources- function libary, datatable
  4. Parameters - input and output parameter
  5. Environment - built in/ user defined variable
  6. XML warehouse
  7. web- broswer navigation timeout, active screen access
  8. java
  9. webservice - web service response timeout
  10. recovery
  11. local system monitor
  12. log tracking

About Error Handling

Error Types in QTP
  1. Syntax error- use ctlr+F7 or view>error
  2. Logical error-
  3. Run time error- can handle in following way.
    1. Test Setting
    2. On error statement- on error resume next, on error go to 0
    3. using Err object - err.description, err.clear, err.source, err.helpcontext
    4. Recover scenario- use to handle unwanted popup, app crash, object stat, test run error etc
    5. Reporter object
    6. Exit statement -exittest, exitaction, exittestiteration


On Error Resume Next
  • Provide some degree of error handling by preventing program interuption from runtime error
  • When error occurs, by using it the line of code containing the error is skipped over and program continues. it doesn't correct the error just ignore it without even displaying error message
  • Turn off the script engine error checking: On error resume next
  • Turn On the script engine to stop execution of a script when an error is encountered: on error go to 0

About ByVal & ByRef

About ByVal & ByRef
  • If argument is variable, array or array element, vb script use ByRef method.
  • If argument is expression then vbscript use ByVal method
  • By default, argument passed to function and subroutine by reference, that is the address of the argument is provided to the function or subroutine.
Example- By Ref
function fun1(ByRef a)
a=a+1
end function
dim x
x=3
call fun1(x)
msgbox x
- output will be 4

Example - ByVal
function fun1(ByVal a)
a=a+1
end function
dim x
x=3
call fun1(x)
msgbox x
-output will be 3