Sunday, 27 February 2011




What is Object?


Object is something, which has structure and properties.

Software Objects:


We call windows, WebPages, buttons, edit boxes, check boxes etc..  as software objects.

Types of Objects in QTP?

         There are 4 types of object available in QTP.

                  Run Time objects
                                                 Test Objects
                                                Utility objects
                     Automation objects / User defined objects

Run time objects: The objects present in the AUT. Ex: Buttons, links, etc…   Run-time objects have different states like Visible, Hidden, enabled, disabled, and focused.

Test Objects: References of Run time objects.  Ex: WinEdit, WinButton, WebButton, Link, etc…  Test Objects are 3types; Constant objects, Dynamic Objects and duplicate objects.
Note: Test objects names vary from one environment to another.

Utility Objects:
         They are QTP reserved objects used for testing and result reporting.
          Ex: 
               1. SystemUtil for launching / closing the application.
               2. Reporter for defining results.
               3. Services for inserting transaction points.
               4. Environment for using environment variables.
Automation objects / User defined objects
User can create objects; those can be used for performing specific operations.  Ex: Creating objects in fie system object class, adodb.Connection class, Dictionary object class, Excel.Application class etc.

  
Test Object is used by QTP to identify an object in the AUT during playback.
Ex: WinEdit, WinButton, WebButton, Link etc…
Important Methods in QTP
QTP provides 4 methods for working on a Test object properties
             ·         GetTOProperty
             ·         SetTOProperty
             ·         GetTOProperties
             ·         GetROProperty

Before learn the above topic we need to know the below topics?
What is the Run Time Object?
While Run Time objects that actually exists in the application. 
What is Test Object Properties?
These properties are some standard set of properties QTP can identify for a given type of object. These properties that QTP stored in the object repository to recognize the object are called Test object properties.
What is the use of Object Spy?
Object Spy can be used to identify either RO or TO properties.
Test objects are the objects that QTP recognizes whereas Run time object are the ones that are mapped by TO's when the test is run.

Test object methods:

GetTOProperty
Get the value of an identification property stored in object repository.
'will display INPUT
Msgbox Browser("Google").Page("Google").GetTOProperty("html tag")

SetTOProperty
Set the value of property for object stored in object repository. This can be used when need to change the identification property at run time. Ex – if a Logout link appear with a user name then we might want to change the identification for that link at run-time

sUsername = 

DataTable("p_UserName")\Browser("X").Page("X").Link("Logout").SetTOProperty "text", _

"Logout " & sUsername
Note: Changes made through SetTOProperty in an Action will have scope of that action only. If you want those changes to be applicable in all action then use Repository parameters
Warning: Make sure you disable Smart identification (SI) for such objects for which you intend to use SetTOProperty.

GetTOProperties
Get all the properties stored for an object in the Object repository. This can be used to loop through all properties of an object

Set allProp = Window("Window").GetTOProperties
For i = 0 to allProp.Count - 1
Print allProp(i).Name & ":=" & allProp(i).Value
Next
All 3 methods discussed above have nothing to do with the actual object (except for identification purpose). I.e. when we use any of the methods above and the object is NOT available on the screen, no error would be thrown.
GetROProperty
This method is used to get the actual property value of the object at run-time. This method would raise an error in case the object does not exist. We can only use the set of
Why GetROProperty instead of GetTOProperty?
GetTOProperty is used only for properties which are used for object identification and GetROProperty can be used for any of the properties that object supports. We might identify an object with lesser number of properties and use its other properties after identifying the object. Also when we use a regular expression in the identification properties (E x – name:=Cancel|Back) then GetROProperty will return actual value which matched the pattern we used (in our case either Cancel or Back)
Note: GetROProperty supports properties which are listed in object spy when Test object Properties radio button is selected. One should not use the properties listed when Run-time object properties radio button is selected.


Now same example with GetROProperty method,

If (Browser("Google").Page("Google").WebButton("Google Search").GetROproperty("x") then
Msgbox “object exists”
Else
Msgbox “object doesn’t exist”
End if

You can also use above method in following way,

If (Browser("Google").Page("Google").WebButton("Google Search").GetROproperty("visible")="True") then
Msgbox “object exists”
Else
Msgbox “object doesn’t exist”
End if



3 comments:

  1. we are offering best devops online training with job support and high quality training facilities and well expert faculty .
    to Register you free demo please visit ,devops training in hyderabad

    ReplyDelete
  2. Very good write-up. I definitely appreciate this website. Continue the good work!
    Devops Online Training
    Adobe cq5 Training
    Dell Boomi Training

    ReplyDelete
  3. I think this is interesting articles and Business ethics for new information's, and i like that kind of information.So the i like that post,because all of given information was very excellent.devops jobs in Hyderabad

    ReplyDelete

TrainingHUB. Powered by Blogger.

Total Pageviews

THE BEST QTP TRAINING INSTITUTE IN HYDERABAD

QTP Training in hyderabad

Sql Tutorial

Popular Posts

Our Facebook Page

TrainingHUB

Followers