Professional Documents
Culture Documents
Keywords:
Introduction:
This document demonstrates the some hidden features of the QTP which could not
found in the QTP documentation. I have found these features by doing R&D on the
product.
Cookies:
Cookies are small chunk of information of code placed by the website on the user
local/browser cache. QTP provides a way to view/delete cookies. The below
mentioned methods can be used for various operation.
WebUtil.<Method>
<Method> Description
DeleteCookie Delete specified cookie for the specified
domain
DeleteCookies Delete all cookies present on the local
cache
GetCookies GetCookies for a specified domain
AddCookie Add specified cookie for a specified
domain
There are many other functions available also. But I would not be going into the
details of any of these. You can find all the function when you type “webutil.” In the
QTP script editor.
For long it has been thought that QTP does not allows creating a checkpoint at run-
time and neither gives a way to modify the checkpoints expected value at run-time.
Well it’s nearly a TRUE statement. But I have found some methods which allow
modifying the expected results of a checkpoint. The checkpoint that I have been able
to modify is only “Standard Checkpoint” and “Text Checkpoint”. Well I think
something is better than nothing.
I would taking examples of the checkpoints below and all checkpoint would created
on http://www.google.com
Standard Checkpoint:
Let us insert a Standard Checkpoint on the Radio button “pages from India”
Now we will see a line added to our QTP script as below
Browser("Google").Page("Google").WebRadioGroup("meta").Check
CheckPoint("meta")
Well let’s take a look at approach that QTP takes. Whenever a checkpoint is created
QTP add a Checkpoint(“<Name>”) object to the script. Now I can use the same
checkpoint on some other object on the page i.e. the checkpoint does not depends on
the object for which was added for. So that means CheckPoint(“meta”) is kind of a
standard object that each an every Check function can understand. That means first
there is a need to have a property which tell which type of checkpoint the
CheckPoint(“meta”) point to. Moving forward all the Checkpoints have something
called checkpoint timeout. So every checkpoint must have these things in common.
Now lets see what happens when we try to access the functions available with the
Checkpoint(“meta”)
Well now I have 4 functions that I can use do something that I don’t know how to
do. Well I know that check and output functions are not one that I would like to use.
Use what I do is try an access CheckPoint(“meta”).GetTOProperty(“html tag”). My
expected output from this statement is “INPUT” string but the result is an error.
Hmmm.....Now how would the check function for an object access the properties of
a checkpoint to test its validity? There has to be something. And yes there is
something… 2 Hidden functions “GetProperty” and “SetProperty”. Know don’t ask
me how I got these two functions. Let see what the script below does
Now looking at the three message boxes it looks like we were able to modify the
expected result of the checkpoint. Now the only problem here is that I didn’t find
any way by which I can check whether that value has to be tested in Checkpoint or
not i.e. I don’t have any way to find whether while creating the checkpoint I have
kept checking option for “all items” as checked/unchecked. Well there would be way
but GOD or MI knows what that is. Any ways we have something to work with. If
we use a item that does not exists in the GetProperty function then it would raise an
error.
Msgbox CheckPoint("meta").GetProperty("checked”)
So you need to be aware of the properties that exist for the given checkpoint.
Unfortunately I also was not able to find a way to enumerate all the properties
present in the given Checkpoint.
Now there are two things left that is the type of CheckPoint and the timeout value
Msgbox CheckPoint("meta").GetProperty("micClass")
Msgbox CheckPoint("meta").GetProperty("step_type")
Msgbox CheckPoint("meta").GetProperty("step_timeout")
Text Checkpoint:
Now let’ insert a text checkpoint “the web” text displayed just after the first radio
button. I would be changing the values of the checkpoint so that later we can see
what all properties are mapped to which name.
The above three snapshots shows all the properties of the given checkpoint. The
below line of code is added to the script
Dim s_Checkpoint
s_Checkpoint=""
s_Checkpoint= s_Checkpoint & "# of occurences for Text Before: " &
CheckPoint("the web").GetProperty("indexoftextbefore") & vbCrlf
msgbox s_Checkpoint
Source Index:
Well source index is actual index of an element in the DOM Tree node. Well QTP
documentation does not give any property for an object which we can use with
GetROProperty to get the value of source index. But this property does exist to be
used with GetROProperty and it is “source_index”.
msgbox
Browser("Google").Page("Google").WebEdit("q").GetROProperty("source_index"
)
Conclusions:
Well after lots of hard work we were able to do the following things
Well if you do find any solution for the above limitation then do contact me at
tarun_lalwani_2000@yahoo.com