Descriptive Programming Simplified | Quick Test Professional(QTP)
.
QTP Blog RSS

Descriptive Programming Simplified

In this post we will discuss:

Introduction to Descriptive Programming.
How to write Descriptive Programming?
When and Where to use Descriptive programming?
Some points to note with
Descriptive Programming.

Introduction to Descriptive Programming:
Descriptive programming is used when we want to perform an operation on an object that is not present in the object repository. There can be various valid reason to do so. We will discuss them later in this article.

How to write Descriptive Programming?


There are two ways in which descriptive programming can be used

1. By giving the description in form of the string arguments.
2. By creating properties collection object for the description.

1. By giving the description in form of the string arguments.

This is a more commonly used method for Descriptive Programming.
You can describe an object directly in a statement by specifying property:=value pairs describing the object instead of specifying an object’s
name. The general syntax is:

TestObject("PropertyName1:=PropertyValue1", "..." , "PropertyNameX:=PropertyValueX")

TestObject—the test object class could be WebEdit, WebRadioGroup etc….

PropertyName:=PropertyValue—the test object property and its value. Each property:=value pair should be separated by commas and quotation
marks. Note that you can enter a variable name as the property value if you want to find an object based on property values you retrieve during a run session.

Consider the HTML Code given below:

<--!input type="”textbox”" name="”txt_Name”"-->
<--!input type="”radio”" name="”txt_Name”"-->

Now to refer to the textbox the statement would be as given below

Browser(“Browser”).Page(“Page”).WebEdit(“Name:=txt_Name”,”html tag:=INPUT”).set “Test”

And to refer to the radio button the statement would be as given below

Browser(“Browser”).Page(“Page”).WebRadioGroup(“Name:=txt_Name”,”html tag:=INPUT”).set “Test”

If we refer to them as a web element then we will have to distinguish between the 2 using the index property

Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html tag:=INPUT”,”Index:=0”).set “Test” ‘ Refers to the textbox
Browser(“Browser”).Page(“Page”).WebElement(“Name:=txt_Name”,”html tag:=INPUT”,”Index:=1”).set “Test” ‘ Refers to the radio button

To determine which property and value pairs to use, you can use the Object Spy:
1. Go to Tools -> Object Spy.
2. Select the "Test Object Properties" radio button.
3. Spy on the desired object.
4. In the Properties list, find and write down the properties and values that can be used to identify the object.


2. By creating properties collection object for the description.

Properties collection also does the same thing as string arguments. The only difference is that it "collects" all the properties of a particular object in an instance of that object. Now that object can be referenced easily by using the instance, instead of writing "string arguments" again and again. It is my observation that people find "string arguments" [1] method much easier and intuitive to work with.

To use this method you need first to create an empty description
Dim obj_Desc ‘Not necessary to declare
Set obj_Desc = Description.Create

Now we have a blank description in “obj_Desc”. Each description has 3 properties “Name”, “Value” and “Regular Expression”.

obj_Desc(“html tag”).value= “INPUT”

When you use a property name for the first time the property is added to the collection and when you use it again the property is modified. By default each property that is defined is a regular expression. Suppose if we have the following description

obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt.*”

This would mean an object with html tag as INPUT and name starting with txt. Now actually that “.*” was considered as regular expression. So, if you want the property “name” not to be recognized as a regular expression then you need to set the “regularexpression” property as FALSE

obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt.*”
obj_Desc(“name”).regularexpression= “txt.*”

This is how we create a description. Now below is the way we can use it

Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc).set “Test”

When we say .WebEdit(obj_Desc) we define one more property for our description that was not earlier defined that is it’s a text box (because QTPs WebEdit boxes map to text boxes in a web page).

If we know that we have more than 1 element with same description on the page then we must define “index” property for the that description

Consider the HTML code given below

<--!input type="”textbox”" name="”txt_Name”"-->
<--!input type="”textbox”" name="”txt_Name”"-->

Now the html code has two objects with same description. So distinguish between these 2 objects we will use the “index” property. Here is the description for both the object

For 1st textbox:
obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt_Name”
obj_Desc(“index”).value= “0”

For 2nd textbox:
obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt_Name”
obj_Desc(“index”).value= “1”

Consider the HTML Code given below:

<--!input type="”textbox”" name="”txt_Name”"-->
<--!input type="”radio”" name="”txt_Name”"-->

We can use the same description for both the objects and still distinguish between both of them
obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt_Name”

When I want to refer to the textbox then I will use the inside a WebEdit object and to refer to the radio button I will use the description object with the WebRadioGroup object.

Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc).set “Test” ‘Refers to the text box
Browser(“Browser”).Page(“Page”).WebRadioGroup(obj_Desc).set “Test” ‘Refers to the radio button

But if we use WebElement object for the description then we must define the “index” property because for a webelement the current description would return two objects.

Getting Child Object:

We can use description object to get all the objects on the page that matches that specific description. Suppose we have to check all the checkboxes present on a web page. So we will first create an object description for a checkboxe and then get all the checkboxes from the page

Dim obj_ChkDesc

Set obj_ChkDesc=Description.Create
obj_ChkDesc(“html tag”).value = “INPUT”
obj_ChkDesc(“type”).value = “checkbox”

Dim allCheckboxes, singleCheckBox

Set allCheckboxes = Browse(“Browser”).Page(“Page”).ChildObjects(obj_ChkDesc)

For each singleCheckBox in allCheckboxes

singleCheckBox.Set “ON”

Next

The above code will check all the check boxes present on the page. To get all the child objects we need to specify an object description.

If you wish to use string arguments [1], same thing can be accomplished by simple scripting.

Code for that would be:

i=0
Do While Browse(“Browser”).Page(“Page”).WebCheckBox("html tag:=INPUT",type:=checkbox, "index:="&i).Exist
Browse(“Browser”).Page(“Page”).WebCheckBox("html tag:=INPUT",type:=checkbox, "index:="&i).Set "ON"
i=i+1
Loop
Possible Operation on Description Objects

Consider the below code for all the solutions
Dim obj_ChkDesc

Set obj_ChkDesc=Description.Create
obj_ChkDesc(“html tag”).value = “INPUT”
obj_ChkDesc(“type”).value = “checkbox”

Q: How to get the no. of description defined in a collection
A: obj_ChkDesc.Count ‘Will return 2 in our case

Q: How to remove a description from the collection
A: obj_ChkDesc.remove “html tag” ‘would delete the html tag property from the collection

Q: How do I check if property exists or not in the collection?
A: The answer is that it’s not possible. Because whenever we try to access a property which is not defined its automatically added to the collection. The only way to determine is to check its value that is use a if statement “if obj_ChkDesc(“html tag”).value = empty then”.

Q: How to browse through all the properties of a properties collection?
A: Two ways
1st:
For each desc in obj_ChkDesc
Name=desc.Name
Value=desc.Value
RE = desc.regularexpression
Next
2nd:
For i=0 to obj_ChkDesc.count - 1
Name= obj_ChkDesc(i).Name
Value= obj_ChkDesc(i).Value
RE = obj_ChkDesc(i).regularexpression
Next

Hierarchy of test description:

When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions
from that point onward within the same statement. If you specify a test object by its object repository name after other objects in the hierarchy have
been described using programmatic descriptions, QuickTest cannot identify the object.

For example, you can use Browser(Desc1).Page(Desc1).Link(desc3), since it uses programmatic descriptions throughout the entire test object hierarchy.
You can also use Browser("Index").Page(Desc1).Link(desc3), since it uses programmatic descriptions from a certain point in the description (starting
from the Page object description).

However, you cannot use Browser(Desc1).Page(Desc1).Link("Example1"), since it uses programmatic descriptions for the Browser and Page objects but
then attempts to use an object repository name for the Link test object (QuickTest tries to locate the Link object based on its name, but cannot
locate it in the repository because the parent objects were specified using programmatic descriptions).


When and Where to use Descriptive programming?

Below are some of the situations when Descriptive Programming can be considered useful:

1. One place where DP can be of significant importance is when you are creating functions in an external file. You can use these function in various actions directly , eliminating the need of adding object(s) in object repository for each action[If you are using per action object repository]

2. The objects in the application are dynamic in nature and need special handling to identify the object. The best example would be of clicking a link which changes according to the user of the application, Ex. “Logout <>”.

3. When object repository is getting huge due to the no. of objects being added. If the size of Object repository increases too much then it decreases the performance of QTP while recognizing a object. [For QTP8.2 and below Mercury recommends that OR size should not be greater than 1.5MB]

4. When you don’t want to use object repository at all. Well the first question would be why not Object repository? Consider the following scenario which would help understand why not Object repository
Scenario 1: Suppose we have a web application that has not been developed yet.Now QTP for recording the script and adding the objects to repository needs the application to be up, that would mean waiting for the application to be deployed before we can start of with making QTP scripts. But if we know the descriptions of the objects that will be created then we can still start off with the script writing for testing
Scenario 2: Suppose an application has 3 navigation buttons on each and every page. Let the buttons be “Cancel”, “Back” and “Next”. Now recording action on these buttons would add 3 objects per page in the repository. For a 10 page flow this would mean 30 objects which could have been represented just by using 3 objects. So instead of adding these 30 objects to the repository we can just write 3 descriptions for the object and use it on any page.

5. Modification to a test case is needed but the Object repository for the same is Read only or in shared mode i.e. changes may affect other scripts as well.
6. When you want to take action on similar type of object i.e. suppose we have 20 textboxes on the page and there names are in the form txt_1, txt_2, txt_3 and so on. Now adding all 20 the Object repository would not be a good programming approach.


References:
1) QuickTestProfessional Documentation
2) Tarun Lalwani's DP Document

If you want to keep track of further articles on QTP. I recommend you to subscribe via RSS Feed. You can also subscribe by Email and have new QTP articles sent directly to your inbox.

Note: Please use the Testing Tools forum for posting questions now!

64 comments:

rajeshwar said...

Hi Ankur,

Thank u 4 clear explain but didn't menssion abt the string arguments for collect multiple objects and operate in application. In my application 100s of links are there, how to collect and test in application. Can you send me model script pls

Thank's
RAjeshwar

dasari said...

i feel very happy about descriptive programming!

but one thing i want u know, what is frame? i.e, test frame work, functional decomposition, keyword frame work, hybread ?

i don't know the frame artichure and purpose of implementation

Ankur said...

Hi Dasari,
In simple terms a framework is a set of guidelines to accomplish a particular task.
In automation parlance you might have heard of data driven/key-word/hybrid framework. For details, you can refer to the "understanding framework" link alongside.

Anonymous said...

hi ankur,
i am really very happy with all the info. Ankur can u plz tell some thing about "Data table methods" and how can they be used.

Anonymous said...

Hi,
Excellent article. cleared lot of doubts abt descriptive programming.
need one more info, is it recommended to completely eliminate the object repository and use descriptive programming. this will improve the performance (if object repository is huge) and by altering various properties one will be able to manage the objects ?

Thanks,
Ramesh Sharma

Anonymous said...

Hi Ankur,
Could you please help me out with a solution regarding
1> how to record "TAB" or "CTRL" i.e key board events.
2> if in a web table , in one of the cells there is a link then how to click it?? If we dont know before hand about the link text.

Ankur said...

@Ramesh:
It is not at all recommended to use DP...Use object repository wherever you can. With DP your test will take more time than object repository method.

HP-Mercury had the limitation of huge object repository till QTP 8.2( They recommend the size to be limited to 1.5KB if you are using QTP8.2 or else you can see frequent crashes)...but for 9.0 and above there is no such limitation.

@Anon:

1) Please tell me in which application you are facing the problem. is it web based/client-server/or any other?

2)for your second query follow this:
1. Get the number of columns and rows in the table. This can be done using the RowCount and ColumnCount methods.
2. Loop through the cells in the table.
3. Get the data value from the cell. This can be done using the GetCellData method.
4. If the data is the value you want, use the ChildItem method to get a reference to the object you wish to click.
Example: Browser().Page().Webtable().childitem(row_number,column_number,"Link").click
5. Use the Click method to click on the data item.

For info on methods and properties you can refer.Help -> QuickTest Professional Help. Click "Object Model Reference".

Anonymous said...

Hey ankur thanks for the reply..for the first query ,
1> The application is web based.

for the second query
My question was not very clear:)
Actually the Child object type is not known.Wherevr the object type is known I have captured the text and created object at run time to operate on them. But in certain cases the object type is not fixed , e.g in cell(2,1) , the content might be a weblink or a radio button , but it is not predefined. I hope this time I am a bit clear.

Sourav said...

Hey Ankur , also wanted to add one thing regarding repositary,
allthough there is no limit in QTP9.0 regarding size , but I have found that the moment the size exceeds 50MB , probability of it being crashed increases...
Again thans a lot for your promt answer for my query regarding clickin a web table cell....

Ankur said...

@ Sourav: A "micTab" statment will press the TAB key only for Windows, ActiveX and Visual Basic Edits.Now since your app is wab based you will have to create your own user defined custom function to do the job. I suggest go for clicking with mouse on the fields rather than tabbing. It will be good for maintenance of your scripts as well.

Thanks for the info regarding obj repository, will take note of it.

Regarding 2nd query Isn't it possible for you to find the type of object at run time and then according to the type , do the required action ( using if radio_button then select() else if link then click())

Anonymous said...

Using DP for all objects will slow down the script. But if OR is used for top level objects (eg. Browser and Page in case of Web application) and remaining in DP, the script will run faster than using just DP for all objects. I have several scripts which create objects on the fly and still run very fast

Anonymous said...

Hi Ankur,

can we make DP using object spy

Achyut Aradhye

Sudhakar said...

Hi Ankur,

You r really helping so much for who wants learn more in qtp and thank you very much

Anonymous said...

hi Ankur,
i would like write external function and want to use it in different places of My script.

My requirement is:
Application:Web Based
i've a web table in that multiple records are there. beside that i've buttons. Based on the records (single,Multiple consecutive, multiple non-consecutive)selection in the web table buttons property will get changed.In most of the pages i need to check this functionality.Could You help me in this regard?

Anonymous said...

I'm automating a web application .My web table accommodates upto 20 records. some times there may be a chance of having less also.how do i check it in QTP?

iravi said...

hi,
am new for QTP scripting plz give some suggetions to approchable guidence,how can we write and get solutions
thanks
r

iravi said...

hi,
am working on web appl,after entering user by giving valid username and paaword,in that page only one weblist1 will open,which dynamic in nature,from this user will select required field,when the user selcting from welist1 corresponding account will appear in another weblist2.
which is my senario plz mail me how can we write in dp programme.
plz its very urgent

iravi said...

give me one example for keyword driven testing,in dp

Govinda said...

How to schedule a Test Batch Runner to run the script automatically without user intervention to press key F5?

Amit said...

Recorded code for my VB-Based application is:

VbWindow("MainForm").VbWindow("LoginForm").VbEdit("vbname := txtPassword" ).SetSecure "474baf160ffc7fe7494752fac902b5597a6bf9c7fe84")
VbWindow("MainForm").VbWindow("LoginForm").VbButton("OK").Click

What will be the DP Code for this?

Ankur said...

@ Amit:

Use "Property Name:= Property Value"
Eg:

VbWindow("WindowName := MainForm")

Govinda said...

Hi Ankur,

How to schedule a Test Batch Runner to run the script automatically without user intervention to press key F5?
or
How to scheduling to run the script automatically?

chitra said...

hi ankur,
in unit testing is there any function for alphabets checking like isnumeric for digits
plz tell me
bye
chitra..

blaze said...

Hey Ankur,,
I hv just started to use QTP 9.2 and am facing some issues with testing frames. for some reason QTP is not recording the objects on a frame. It is showing the frame in Active Screen but it is completely blank.
Can you pls tell me about how to test frames and the objects in it..

Thanks heaps.

Anonymous said...

Hi,

We are using QTP 9.2 and are using OR instead of DP. The only issue that we are facing with QTP is that it is not very reliable at all times, and misses out on certain UI actions (say button clicks) intermittently. The same script will work fine on a box but will fail intermitently without any reason.

Do you reckon we switch to DP to resolve this issue. My personal view is that if i am using OR object with a set of properties, and using DP to define that object with same set of properties; then from reliability perspective, it will NOT make any difference; so this aspect remains same even if we use DP or OR

-Bipan

Anonymous said...

Hi Ankur,

I used QTP before on web application, now I am working on client/server vb .net application.

I am trying to get the row and col count of a table however qtp stops at this step and does not throw any error but its still in running state.

Code:

RowCou = SwfWindow("frmMain").SwfWindow("frmLeadSearch").SwfTable("dgvLeads").RowCount

None of the methods column count, get cell data are not working apart from DblClick row,col any row or col value clicks on the last row of the table.

Please do let me know how can I work with these tables.

Thanks

Vikas said...

Hi Ankur,

This is truly a fantastic article.
You have explained your point with the simplest and best examples possible.

Thanks a lot for posting this.

Regards
Vikas

lingam said...

Hi Ankur
This is kiran.i want to know, how to connect to mysql from qtp.Can u plz give me code

regards
kiran

Anonymous said...

Hi

Is it possible to count number of objects in the web page and then tab through them using DP?

Ankur said...

Hi All,

Please use Testing Tools forum to post your QTP questions!

sanjay said...

Hello Ankur Sir,
Can you solve my problem? Is it necessary to have a knowledge of VBScript for QTP testing? If we test the application through descripted programming,it reduce the time or consume the time?

kiran said...

Hi Ankur,

I have 10 links in a webpage with same name "Continue".

I want to randomly select one "Continue" link among those ten links.

I tried to retreive using Childobjects as follows..

=================================

Set oDesc = Description.Create()

oDesc("Class Name").Value = "Link"
oDesc("name").Value="Continue"
oDesc("innertext").Value="Continue"


Set Links = Browser("B1").Page("B1").ChildObjects(oDesc)

NumberOfLinks = Links.Count()


i=RandomNumber(1,10)

Links(i).Click

The above code is not working can you please suggest a solution for this.

Your help is appreciated

Anonymous said...

Hi,

A great article for descriptive programming.

Please help me with a query regarding special characters in the value i.e.

obj_Desc(“html tag”).value= “INPUT”
obj_Desc(“name”).value= “txt.*”

If my obj_Desc(“name”).value contains parantheses ( or ) [for eg obj_Desc(“name”).value="ABC(A)"] then code fails at the following step:

Browser(“Browser”).Page(“Page”).WebEdit(obj_Desc)

Any idea how to deal with it??

Thanks,
S

madhavan said...

Hi,
I am trying to automate the hierarchy tree in our web application.I am experiencing the problem in navigation.since each level is having unique property set.

I wish to automate the hierarchy navigation based on user input data..

Can any one help me out in this

Thanks in advance
Regards,
Madddy

Anonymous said...

Hey Madddy,

Can you be more specific about the problem and what exactly are you trying to achieve. The earlier description is pretty vague.

MRR

sutnarcha said...

Hi Ankur,

I must say this blog is very informative and I got to learn a few new things from it.

But, I guess this part of your code snippet doesn't work...

For each desc in obj_ChkDesc
Name=desc.Name
Value=desc.Value
RE = desc.regularexpression
Next

It gives an error...
Object doesn't support this property or method

The other method using a counter in the For loop works fine.

Laxmi said...

hai this is laxmi can you please give me the program for flight reservation application.i am working on vc i recorded some functions but i am doing the same with descriptive they are not functioning do you know why it is happening please help me.my email id lakshmi.jyoshna#gmail.com

Anonymous said...

Hi Ankur,

i want to use DP for selecting a row in web table. can you please tell me how to do that? i need just hint. please help me out.

Anonymous said...

Hi Ankur,

Your blog regarding descriptive programming is very good and given me a good picture abt DP. Really I appreciate your job.

Thanks..

Anonymous said...

Hi Ankur, good article.

Have two questions i hope you have answer.

How to regular expression works with descriptive programming in qtp 9.5 ?

VB script has performance penalty if it uses regular expression -- is it true qpt scripts execution also decrease performance if descriptive programming is used?


Thanks in advance,
NV

Ankur said...

@NV:
How to regular expression works with descriptive programming in qtp 9.5 ?

Just as they work with other versions. There is no change.

VB script has performance penalty if it uses regular expression -- is it true qpt scripts execution also decrease performance if descriptive programming is used?
ya the effect becomes pronounced when you have a lot of descriptive programming code in the script. For smaller scripts there is no minimal difference.

Tanuj....trying to be the chauvinist!! said...

Hi Ankur, In my java application objects are recognised properly in OR. There are 4 radio buttions in the page. They're getting recognised by OR but I can use only descriptive programming. I have used all the possible combinations of it's properties to recognise the object but it doesn't. All other objects get recognised with Descriptive method.
I've used "attached text","developer name","path" etc all the combinations but the object is not getting recognised. Could u pls help me resolve this issue. Or should I explore on using extern.declare method for the DLLs?

rajiv1942 said...

Hi Ankur, I read your posts it is really helpful. Can you give an example in which scenarios(real application scenario) regular expressions r used and how it will be used small pseudo code?
Thanks
Waiting for your response!!

harish said...

Harish


Hi Ankur,will u plz explaing detally the concepts of Library files and Framework

Anonymous said...

Hi Ankur,
Thanks for your help on DP. However, I get stuck when the spy does not recognise an object on a window or in a frame. When recording it says some generic term. Properties window displays all blank. What properties should I use in this case?

Anonymous said...

I would like to check if Descriptive Programming is the means to rescue, if QTP fails to recognize objects in your web application. Can someone advise as to where you can find a compelte text for methods of Descriptive Programming ? I find a little bit here and there on the web.

Anonymous said...

Hello All,

I am new to QTP and DP and would like to know if DP technique is better than OR ? From what I hear from my team is that
DP is useful only 1) when the application to be tested is in under construction mode but its interface design is available.
and 2) also, if using Mercury than... Mercury had the limitation of huge object repository till QTP 8.2 (They recommend the size to be limited to 1.5KB if you are using QTP8.2 or else you can see frequent crashes)...but for 9.0 and above there is no such limitation.


Any thoughts on above or when DP is useful ?


Thanks,
Mayank

Anonymous said...

Hi Ankur

Is it possible to write a vb script in descriptive programming and run the same using Vbscript editor,instead of QTP??
If so please let em know, how could we start of with

Rgds
Ravi

RR said...

Hi all,

I am using QTP to test a java application. The software I am testing has lots of the same fields but with different labels (as per client requirements). I have added an object in the repository and updated it to use a regular expression instead of a static value. Shouldn't this work? I am new with QTP and couldn't find any advance book to search for a better solution. I am just not wondering to have to put all objects in the repository.
Thoughts anyone?
Thanks

chad said...

QTP for GMail Example. Substitute user id and password with your gmail user id and password.

BEGIN QTP

Browser("Name:=Gmail: Email from Google").Page("Title:=Gmail: Email from Google").WebEdit("Name:=Email").Set "your e-mail"
Browser("Name:=Gmail: Email from Google").Page("Title:=Gmail: Email from Google").WebEdit("Name:=Passwd").SetSecure "your password"
Browser("Name:=Gmail: Email from Google").Page("Title:=Gmail: Email from Google").WebButton("Name:=Sign in").Click

Set obj_ChkDesc=Description.Create()
obj_ChkDesc("html tag").value ="A"


Set allLinks = Browser("Name:=Gmail - Inbox.*").Page("Title:=Gmail - Inbox.*").ChildObjects(obj_ChkDesc)
x= allLinks.count()
MsgBox x

'Click SPAM mailbox in your GMAIL


MsgBox allLinks(34).GetRoProperty("text")

For i = 0 to x-1

'MsgBox allLinks(i).GetRoProperty("text")

If UCase(Left( allLinks(i).GetROProperty("text"), 5)) = "INBOX" Then
MsgBox "There are " & Right(allLinks(i).GetROProperty("text"), 4) & "mails in your InBox"
allLinks(34).click()
Exit For
End If

Next

'Sign Out

allLinks(27).click()

END QTP

chad said...

Cleaner code for Gmail access using QTP for demo of descriptive programming


' Sign In. The application URL is set in Record Settings in QTP. Not using SysUtil

Browser("Name:=Gmail: Email from Google").Page("Title:=Gmail: Email from Google").WebEdit("Name:=Email").Set "ur e-mail"
Browser("Name:=Gmail: Email from Google").Page("Title:=Gmail: Email from Google").WebEdit("Name:=Passwd").SetSecure "ur password"
Browser("Name:=Gmail: Email from Google").Page("Title:=Gmail: Email from Google").WebButton("Name:=Sign in").Click

' The Frame object in Gmail ( IFRAME) comes with dynamic values each time we access the application.
We need to capture the IFRAME name for Sign Out and InBox links. The dynamic frame name is captured in x
Total there are 4 frames in GMAIL and the third frame contains Sign Out and InBox

Set obj_ChkDesc1=Description.Create()
obj_ChkDesc1("html tag").value ="IFRAME"
Set allFrames = Browser("Name:=Gmail - Inbox.*").Page("Title:=Gmail - Inbox.*").ChildObjects(obj_ChkDesc1)
x = allFrames(3).GetRoProperty("name")

' Click InBox

Browser("Name:=Gmail - Inbox.*").Page("Title:=Gmail - Inbox.*").Frame("name:=" &x).Link("text:=" &”InBox.*”).click

' Click Sign out

Browser("Name:=Gmail - Inbox.*").Page("Title:=Gmail - Inbox.*").Frame("name:=" &x).Link("text:=Sign out").Click


Question to Ankur / Readers ( Please help )

Like whatever I did for Frame I captured the InBox link with actual unread mail.I used the following code but the code is not working.
Here y is Inbox(whatever number your mail is captured dynamically). But this code does not work at all.

y = InBox ( 76 ) - 76 is given for example but I captured the exact number of unread mails in my mailbox.
When I susbtitue here as i did for FRAME this does not work. That is why I used wild character above.
I chekced the frame name and for the given session the IFRAME name for InBOx and Sign Out is same.

Browser("Name:=Gmail - Inbox.*").Page("Title:=Gmail - Inbox.*").Frame("name:=" &x).Link("text:=" & y).click

Anonymous said...

Hi ankur...
exacellent job... really gr8..article..
thanks alot...

harish said...

hi ankur,

whether it is possible to capture snapshot when run time error occurs using QTP 9.5........
the snapshot should be in excel or pdf file,by using movie recorder it is capturing all the sanpshots but i want only runtime error

Sandeep said...

Hi Ankur,

It is really a good example to understand the descriptive programming but I am facing the problem to click on a WebElement which comes under multiple WebTables like Browser->Page->WebTable->Webtable->WebTable->WebTable->WebElement.

I want to click on the WebElement which is following the above hierarchy. So I will be very thankful if you will help me to get rid from this problem and provide me the solution.

If anybody have the solution apart from Ankur please help me.

~Sandeep

Anantha said...

Hi Ankur,
This is AnanthaKrishnan.Your are doing an Excellent service. first of all ,i thank u very much for giving us such a fabulous article which really making me to understand easily and clearly.If ever any doubt in that,i write to u ,please help me with your reply

mahesh said...

Am working with Windows based application developed in VB

Is there is any spl thing needs to be done for a descriptive programming for windows application

There examples what had refered is related to webapplication

If am following the same whetherit will work

Anonymous said...

Hi Ankur.

I'm have problem with creating 1 run time object out of two.

For example:
I have webtable object that has 2 columns and 5 rows, so there are 10cells i.e. 10 odjects because each cell treated as single odject.

Is that possible to create 5 objects basing on principle that 1 row is one object?

If yes please describe.

Thanks,
George

Ravinder Singroha said...

Hi Ankur

I am having a problem in QTP, I need to clear the Radio button selection with Descriptive programming in VB,
I have done this in WATIR and SELENIUM but in QTP its still a mystery for me.

Please guide me

Thanks
Ravinder Singroha

Vij said...

Hi Ankur,

I have seen your posts on this blog and they are very helpful..

I have a problem, that is I need to get all the objects of an application into an excel sheet as how you get into your OR in QTP..

I should not any Object Repository in QTP and should use the Excel sheet where I got the objects as my OR..

I've succeded in getting the objects dynamically into an excel sheet.. But not finding a solution to write a script, basing this excel sheet as an Object Repository and those objects which are stored in that Excel..

Kindly help me out as it is a very hight priority issue..

Thanks
Vij

sagar said...

Hi Ankur...
exacellent job... really greate article.
Appriciate your information that u have given abt DP

Thanks alot...

abhikansh said...

what is the difference between Description.Createobject() and Description.Createobject and Createobject("")?

Anonymous said...

How do you use QTP to test SOLR indexing data

Anonymous said...

Hi Ankur,
Great article....
Have one question regarding independent actions.

I have created three actions in one test (Action1, Action2, Action3).

Now when i run test i want after completion of "Action1" it should directly goto "Action3" and not executing "Action2" ...
how do i do this...
kindly help.

Chandu said...

Hi Ankur

This is chandra sekhar
I am working on a dot net application, yes i am a learner in qtp,there will be a text area where the doc id is generated by the application,please let me know how to recognize that using qtp , i need that id for further processing of the application process
please let me know its urgent