Sunday, June 28, 2015

Descriptive Programming


- WebEx training notes:
Descriptive Programming: Helps you to manipulate objects without use of Object Repository.

Major dis adv --- will need to add everything in the code.

Advantage - Performance will be high.
Two ways of writing Descriptive programming:

1. Descriptive Strings
2. Descriptive Objects

or
1. Static (Strings)
2. Dynamic (Objects)

Descriptive Strings:

Browser("<propertyname1>:=<name>", "<propertyname2>:=<name>").Page("<propertyname1>:=<name>","<propertyname2>:=<name>").Web......

Descriptive Objects:

set browobj = Description.Create

browobj("<propertyname1>").value="<name>"
browobj(<propertyname2>").value="<name>"
....

Set pageobj = Description.Create

pageobj("<propertyname1>").value="<name>"
pageobj("<propertyname2?").value="<name>"
..

Set webelementobj = Description.Create

webelementobj("<propertyname1>").value ="<name>"
webelementobj("<propertyname2>").value ="<name>"
...

Browser(browobj).Page(webelementobj).WebElement(webelementobj).....

'*************************************************************


What is micClass?  --- Not Solved

set obj1 = Browser(browobj).Page(webelementobj).ChildObjects(webelementobj)

obj1.Count '-- this gives the number of webelementobjects under that page

So it saves lot of your time, going to each and every object we can just use childobject method.

And each element could be accessed as below:

For i =0 to obj1.Count-1
obj1(i).set "<value>"    '----sets value to the each of the webelement in a web page.
Next










-
Why to use Descriptive Programming:
Source: http://www.qtpschool.com/2014/09/why-use-descriptive-programming-dp-in.html


Scenario 1. - you need to count how many search result are returned when you search a particular search criteria. For example, you want to see how many 
qtp/selenium/agile/java jobs are posted on a job portal in last 2 days! you then want to select all and apply.

Because you dont know in advance how many checkboxs will be there on search result, you cant use object repository.

Using DP (childobject), you can easily handle this scenario.

Scenario 2. - you are working on automation of an application where latest code is not deployed yet. To use OR, you must wait untill application is up and running. But if know the object descriptions, you can continue to create you automation scripts using DP.

Scenario 3. - your application is having 10 pages and every page has 2 same button i.e. "Previous Page" and "Next Page". So if use OR, it will add 2 objects for each page i.e. total 20 object for 10 pages. Instead of having 20 duplicate objects and making our OR unnecessarily 'bulky, we can simply write 2 DP objects.

Scenario 4. - Descriptive Programming is very useful for tricky objects like blotter grids, auto-hiding menus and embeded/nested objects and advanced string manipulations.

Scenario 5. - It might not sound a great example but suppose your qtp server is crashed and you can not open/access qtp OR for a while (1-2 days). If you use OR, you have wait until server is back, but you can continue to work if you use DP (advanced users).

Hope above are enough reasons to answer why to use DP at all!!

No comments:

Post a Comment