Saturday, September 7, 2013

Dynamic Descriptive Programming

Entering Objects Information directly into the test script is called descriptive programming. In DP, we will be "manually" specifying the set of properties and values by which the relevant object will be identified. This way QTP won’t search for the properties data in the Object Repository, but will take it from the DP statement directly.

Object Spy is used to get the properties and their values to uniquely identify the objects in the application. If we know such properties and their unique values that can identify the required object without ambiguity, we need not use Object Spy.

Two ways of descriptive programming:

1. Static Programming: We provide the set of properties and values that describe the object directly in a VBScript statement.


2. Dynamic Programming: We add a collection of properties and values to a Description object, and then enter the description object name in the statement.



'Dynamic Descriptive Programming
'*************** Dynamic descriptive Programing **************
'**************** Page Used: Google - Products****************

'Launch Google - Products
Systemutil.Run "iexplore.exe","http://www.google.com/intl/en/about/products/"

'Descriptive object to identify  Browser  with a particular title
Set  Dbrowser=Description.Create
Dbrowser("micclass").Value="Browser"
Dbrowser("name").Value="Google - Products"

'Descriptive object to identify  Web page with a particular title
Set  Dpage=Description.Create
Dpage("micclass").Value="Page"
Dpage("title").Value= "Google - Products"

Browser(Dbrowser).Page(Dpage).Sync  'wait till browser sync

'Descriptive object to identify a  particular Link
Set  DLink=Description.Create
'DLink("micclass").Value="Link"
DLink("html tag").Value="A"

Set objLinkCount=Browser(Dbrowser).Page(Dpage).ChildObjects(DLink) 'Returns the childobjects having 'Linkobject' description.
vrDLinkCount = objLinkCount.Count  'Returns number of links on webpage
MsgBox vrDLinkCount

For i=0 to vrDLinkCount-1
                vrTag = objLinkCount(i).GetROProperty("name")
                vrHREF = objLinkCount(i).GetROProperty("url")
                msgbox vrTag & ": " &vrHREF

Next