Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the responsive-lightbox domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the hueman domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/wp-includes/functions.php on line 6114
Descriptive programming - Testingpool

Descriptive programming

Descriptive programming is very powerful concept in UFT. Descriptive programming can be considered for the following scenarios.

1. Application is having many dynamic objects. Dynamic objects are the objects whose properties are not constant ,instead they will change very frequently.

2. It will by pass the object repository. If object repository’size is huge.Loading repository and maintaining such a big repository can become a challenge.

3. Execution will be faster.

4. Without knowing the unique properties of the objects, it is easy to get the collection of the similar objects an work on that.

5. If multiple people are using shared object repository, then updating object repository and accessing it becomes troublesome if it is used by any other person at the same time. It will be in read -only mode.No such case with descriptive programming.

6. In keyword driven programming. Suppose, if application is not ready yet but you know the properties description of the objects. You can create the objects with those description and objects will be used when application is available.

Types of descriptive programming:

1. Static DP
2. Dynamic DP

Static DP: A line of code creates an object by using the objects properties and values.
E.g. Consider, you need to create an webedit object without adding it to the repository. The pair of property and value is used to define an object.
Read the properties of the object using object spy and then use them in defining object as shown below.

Syntax: Object(“Property1:=value1″,Property2:=Value2”)

We can use multiple property and value combination.

'Browser and page are taken from OR and webedit descriptive programming
Browser("Add Job").Page("Add Job").WebEdit("html id:=edit123","name:=username").Set "your value"

'or 
'All 3 objects browser ,page , webedit uses descritive programming
Browser(“micclass:=Browser”).Page(“micclass:=Page”).WebEdit("html id:=edit123","name:=username").Set "your value"
Note: Note:
– We can use the object repository object as parent object and child object as descriptive programming but vice versa not possible. As you can see in the example – browser and page are taken fro object repository and webedit uses descriptive programming. – We can write the whole object in descriptive programming only.

We can use regular expression as well as ordinal identifiers.

'Regular expression in webedit. Use '.*'
Browser("Add Job").Page("Add Job").WebEdit("html id:=edit.*","name:=username").Set "your value"

'Using index ordinal identifier
Browser("Add Job").Page("Add Job").WebEdit("html id:=edit123","name:=username","index:=0").Set "your value"

 


 

Dynamic DP: It can be used to identify the identical objects or get the collection of the childobjects under any parent objects.

E.g. Suppose, There are n no. of links on a page and we need to count the no. of links and print their text as well.In this case, we will create a description object and extract these links(childobjects) under the page(Parent object).

 'Create a description object
Set oDesc = Description.Create
oDesc("micclass").value = "Link"
' Get child objects links
Set oColl = Browser("name:=Google").Page("title:=Google").ChildObjects(oDesc)

'Get count of links on page
msgbox oColl.count
'print text of all linka found
For i = 0 to oColl.count-1
  print oColl(i).GetRoProperty("text")
Next

 

Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...