Descriptive Programming :
QTP identify the object by property and method of object which present in the object repository.But desciptive programming is used when perform operation in object which is not present in the object repository.
How to do DP?
We can achieve this below two kind of operation.
1) placing the set of property and values directly in statement :
we can describe the object directly in statement by using
PropertyName:=Propertyvalue
General Syntax:
TestObject("PropertyName1:=PropertyValue1",.... "PropertyNameX:=PropertyValueX")
TestObject - The test object like WinEdit,WebButton,WebList etc...
PropertyName - Its identify object peroperty name
PropertyValue - Its identify object peroperty Value
Both are seperated by commas and should enclosed by quotation marks.
Consider below example using OR
Browser("Google").Page("Google").WebEdit("q").set "QTP referance"
Below example using DP
Browser("Google").Page("Google").WebEdit("type:=text","name:=q","html tag:=INPUT").Set "QTP referance"
you can use the variable if u want to use the variable value. you can assign the value into the variable name.
using above example
Myvar="q"
Browser("Google").Page("Google").WebEdit("type:=text","name:="&Myvar,"html tag:=INPUT").Set "QTP referance"
2) Using Descriptive object:
we can use the description object to return the property collection object containing the set of property objects. The property objects contains property name and value.
Using description object we can isert data into the Edit box in google search home page
Set MyDesc= Description.Create()
MyDesc("type").value="text"
MyDesc("name").value="q"
MyDesc("html tag").value="INPUT"
Browser("Google").Page("Google").WebEdit(MyDesc).Set "QTP referance"
Hierarchy of specifying test object description
Providing Property and value directly to the QTP script for identify the object without using object repository is called the programmatic description.
If we use desciprtive programmin in the statement of the script, its not allowed to use the object repository method in the statement,
Valid Statment in the script (Using the DP and description object)
Set MyDesc= Description.Create()
MyDesc("type").value="text"
MyDesc("name").value="q"
MyDesc("html tag").value="INPUT"
Browser("Title:=Google").Page("Title:=Google").WebEdit(MyDesc).Set "QTP referance"
Invalid statement in scripts( Using DP and OR)
Browser("Title:=Google").Page("Title:=Google").WebEdit("q").Set "QTP referance"
Inabove statment the WebEdit("q") object located from OR. the QTP is not retrive this object from OR because the parent object (Browser) is specified using descriptive programming.
Identify the property and values to be used in DP.
To identify the property and values for the object by using the Object spy or object repository manager.
In All object property window (OR manager), we can identify the correct property and values.Here in below description properties we have the property name and values.
micClasss
In general, there are no such property names are available to deal deirectly with browser( we dont see the any kind of description property in OR for browser). In this case we have the dummy property is avilable for dealing with browser that is called micClass. Sice descriptive property expect atleast one property.
the below code is not work,because there is no logical name or property name to identify the browser.
Browser("").refresh
This is correct format as in below
Browser("micClass:=Browser").Refresh
micClass is used for the class type of the test object like Browser,Page,WebLiast,WebButton etc,
Script1:
Click google Search button using properties in the step
Browser("Title:=Google").Page("Title:=Google").WebButton("type:=submit","html tag := INPUT","name:=Google Search").click
Script 2:
Click Google Search button using description object
Set googlesearchobj=Description.Create()
googlesearchobj("type").value="submit"
googlesearchobj("html tag").value="INPUT"
googlesearchobj("name").value="google search"
Browser("Title:=Google").Page("Title:=Google").WebButton(googlesearchobj).click
Script 3:
Adding and removing properties of an object in DP
set googlesearchobj=Desciption.Create()
Set googlesearchobj=Description.Create()
googlesearchobj("type").value="submit"
googlesearchobj("html tag").value="INPUT"
Set addobj=Description.Create()
addobj("name").value="Google search")
googlesearchobj.add addobj(0)
Print("Number of properties" &googlesearchobj.count)
googlesearchobj.remove "type"
Script 4:
print the name of all links present in the application
Set linkDesc=Description.Create()
linkDesc("html tag").value="A"
Set googlelinks= Browser("Google").Page("Google").ChildObjects(linkDesc)
Print ("Nnumber of linkns are in this web page" &GoogleLinks.count)
for i=1 to googlelinks.count-1
Print("Name of the liks present in tha application"&googlelinks(i).getROProperty("text")
next
Explain:
-> linkDesc("html tag").value="A" (A meand "Anchor" represent links)
-> ChildObjects - Retrive all Child objects in the web page.
-> GetROProperty - return the property value.
Script 5:
Select all check box in the Gmail Inbox
Set checkboxdesc= Description.create()
checkboxdesc("type").value="checkbox"
set checkboxccollection= Browser("Google").Page("Google").Frame("Mails").WebTable("Inbox").ChildObjects(checkboxdesc)
for i=1 to checkboxcollection.count
Checkboxcollection.set "ON"
next
QTP identify the object by property and method of object which present in the object repository.But desciptive programming is used when perform operation in object which is not present in the object repository.
How to do DP?
We can achieve this below two kind of operation.
1) placing the set of property and values directly in statement :
we can describe the object directly in statement by using
PropertyName:=Propertyvalue
General Syntax:
TestObject("PropertyName1:=PropertyValue1",.... "PropertyNameX:=PropertyValueX")
TestObject - The test object like WinEdit,WebButton,WebList etc...
PropertyName - Its identify object peroperty name
PropertyValue - Its identify object peroperty Value
Both are seperated by commas and should enclosed by quotation marks.
Consider below example using OR
Browser("Google").Page("Google").WebEdit("q").set "QTP referance"
Below example using DP
Browser("Google").Page("Google").WebEdit("type:=text","name:=q","html tag:=INPUT").Set "QTP referance"
you can use the variable if u want to use the variable value. you can assign the value into the variable name.
using above example
Myvar="q"
Browser("Google").Page("Google").WebEdit("type:=text","name:="&Myvar,"html tag:=INPUT").Set "QTP referance"
2) Using Descriptive object:
we can use the description object to return the property collection object containing the set of property objects. The property objects contains property name and value.
Using description object we can isert data into the Edit box in google search home page
Set MyDesc= Description.Create()
MyDesc("type").value="text"
MyDesc("name").value="q"
MyDesc("html tag").value="INPUT"
Browser("Google").Page("Google").WebEdit(MyDesc).Set "QTP referance"
Hierarchy of specifying test object description
Providing Property and value directly to the QTP script for identify the object without using object repository is called the programmatic description.
If we use desciprtive programmin in the statement of the script, its not allowed to use the object repository method in the statement,
Valid Statment in the script (Using the DP and description object)
Set MyDesc= Description.Create()
MyDesc("type").value="text"
MyDesc("name").value="q"
MyDesc("html tag").value="INPUT"
Browser("Title:=Google").Page("Title:=Google").WebEdit(MyDesc).Set "QTP referance"
Invalid statement in scripts( Using DP and OR)
Browser("Title:=Google").Page("Title:=Google").WebEdit("q").Set "QTP referance"
Inabove statment the WebEdit("q") object located from OR. the QTP is not retrive this object from OR because the parent object (Browser) is specified using descriptive programming.
Identify the property and values to be used in DP.
To identify the property and values for the object by using the Object spy or object repository manager.
In All object property window (OR manager), we can identify the correct property and values.Here in below description properties we have the property name and values.
micClasss
In general, there are no such property names are available to deal deirectly with browser( we dont see the any kind of description property in OR for browser). In this case we have the dummy property is avilable for dealing with browser that is called micClass. Sice descriptive property expect atleast one property.
the below code is not work,because there is no logical name or property name to identify the browser.
Browser("").refresh
This is correct format as in below
Browser("micClass:=Browser").Refresh
micClass is used for the class type of the test object like Browser,Page,WebLiast,WebButton etc,
Script1:
Click google Search button using properties in the step
Browser("Title:=Google").Page("Title:=Google").WebButton("type:=submit","html tag := INPUT","name:=Google Search").click
Script 2:
Click Google Search button using description object
Set googlesearchobj=Description.Create()
googlesearchobj("type").value="submit"
googlesearchobj("html tag").value="INPUT"
googlesearchobj("name").value="google search"
Browser("Title:=Google").Page("Title:=Google").WebButton(googlesearchobj).click
Script 3:
Adding and removing properties of an object in DP
set googlesearchobj=Desciption.Create()
Set googlesearchobj=Description.Create()
googlesearchobj("type").value="submit"
googlesearchobj("html tag").value="INPUT"
Set addobj=Description.Create()
addobj("name").value="Google search")
googlesearchobj.add addobj(0)
Print("Number of properties" &googlesearchobj.count)
googlesearchobj.remove "type"
Script 4:
print the name of all links present in the application
Set linkDesc=Description.Create()
linkDesc("html tag").value="A"
Set googlelinks= Browser("Google").Page("Google").ChildObjects(linkDesc)
Print ("Nnumber of linkns are in this web page" &GoogleLinks.count)
for i=1 to googlelinks.count-1
Print("Name of the liks present in tha application"&googlelinks(i).getROProperty("text")
next
Explain:
-> linkDesc("html tag").value="A" (A meand "Anchor" represent links)
-> ChildObjects - Retrive all Child objects in the web page.
-> GetROProperty - return the property value.
Script 5:
Select all check box in the Gmail Inbox
Set checkboxdesc= Description.create()
checkboxdesc("type").value="checkbox"
set checkboxccollection= Browser("Google").Page("Google").Frame("Mails").WebTable("Inbox").ChildObjects(checkboxdesc)
for i=1 to checkboxcollection.count
Checkboxcollection.set "ON"
next
No comments:
Post a Comment