Forum Discussion
- prakashkOccasional ContributorHi,
Yes, we can do descriptive programming in Test Complete Tool.
Here are the example for Gmail Login Page:
1st Step: Click on Map Object icon -> Drag the Target Point to the Object -> Save a whole Page Object in Name Mapping.
Ex: Map Name: pageGmailLogin
After Saving the Page Object then Name Mapping shows Tree Model. like--> sys-IEXPLORE-pageGmailLogin
Sub GmailLogin()
Set iexplore = Aliases.IEXPLORE
Set Page = iexplore.pageGmailLogin
Page.Wait
' Enter User Name
NameProperty = Array("ObjectType", "ObjectIdentifier")
ValueProperty = Array("Textbox", "Email")
UserName = Page.FindAllChildren(NameProperty, ValueProperty, 7)
UserName (0).SetText ("prakash")
End Sub
'For Finding Objects, we need to click on object spy, and pass the Unique Name Properties and Value Properties
'7 = Depth of the User Name
Hope this will needful for you.
Thanks,
Prakash
prakashraju06@gmail.com - krupa_lukeOccasional ContributorHi,
I have been working with QTP (UFT) for years and now I am slowly uncovering capabilities of TestComplete.
Descriptive programming (defining test objects via properties and corresponding values) was one of the first things I was interested in.
In QTP (UFT), syntax of descriptive programming looked like this:
Browser("prop1:=val1", "prop2:=val2")
... the same in testComplete:
Sys.Browser(prop1="val1", prop2=val2)
Note:
Please, notice that in case of val1 I used apostrophe ("val1"), while in case of val2 I did not. So in used syntax example above val1 is a String data type while val2 is an integer.
example:
Sys.Browser(ObjectIdentifier="iexplore", BrowserIndex=1)
Hope this helps :-) - Colin_McCraeCommunity Hero"if you want use it as a generic function then we need to start from top level i think so!"
No.
No you don't.
You simply pass it the object you want to search down from as a parameter. It remains generic. Simple.
If you were looking for lines in a book, would you start from the front page every time if it was possible to start from the chapter or paragraph instead? - RavikSuper ContributorHi guys..
Prakash Konduru is explain descriptive programming concept very well with example.
Using Find, FindAll, FindChild, FindAllChilderen methods we can performed descriptive programming in TestComplete. (all the above methods will help for Dynamic Descriptive programming).
3- Find : - This method is used to search the object from the TestedObj hierarchy.This method searches an object with the specified values of the specified properties. here search starts from TestedObj parent node and continue upto the depth mention.
Syntax
Set myObject = TestObject.Find(PropertyName, PropertyValue, Depth)
Example - Suppose you want to search "gmail link" on google page, We will write Descriptive programming like -
Set lnkgmail = Sys.Browser("IExplorer").Page("google.com").Find("ContentText", "gmail", 10)
Here -
1- Property Name = ContentText
2- Property Value = gmail
3- Depth = 10
4- FindChild : - A TestedObj may have one or more child objects with specified values of the specified properties so in this case we will using FindChild Method. FindChild method searches child objects from the TestedObj.
Syntax -
Set myObject = TestObject.FindChild(PropertyName, PropertyValue, Depth)
Note - The difference between Find and FindChild is that, FindChild searches child objects, while Find searches TestedObj only.
5- FindAll : - FindAll method is used to search desire object from the TestedObj hierarchy. FindAll Method searches the entire object that have Specified value of the Specified properties. it's return a collection of objects and stored entire object list into an Array.
Syntax -
Set myObject = TestObject.FindChild(PropertyName, PropertyValue, Depth)
6- FindAllChildren : – FindAllChildren method is same as FindAll method (as mention above), it will search all the children and store them into an Array.
Set myObject = TestObject.FindAllChildren(PropertyName, PropertyValue, Depth)
Note - We can search a object with the combination of multiple properties and values. Suppose we want to search gmail link which is enabled on page, so in this case we will need to define arrays for Property Name and Property Value and use them like below-
Example
PropertiesName = Array ("ContentText","ObjectType", "Enabled")
PropertieValue = Array("gmail","Link", "True")
Set myObject = TestObject.FindChild(PropertiesName, PropertieValue, 100)
This May help you.
- Colin_McCraeCommunity HeroEh?
I presume "strPropVal1,strPropVal2,strPropVal3,strPropVal4" are all meant to be passed into the function?
And you've also hardcoded the properties available to search on, which is restrictive.
What you've posted will work, but it's using a bazooka to kill a fly. If your pages has a lot of objects, that function will be very inefficient as you're starting at the top level (Page) for every object.
What would make more sense would be to pass it a top level object and also the properties, and their values, that you want to search for. Then build and execute a command to search the child objects of the passed in object based on the parameters and the values. It might also be a good idea to pass in the depth you want it to search. - SriniGContributorThank you Colin McCrae for your suggestionsJ. If you are looking for only particular lines from single book then as you said its correct but if you want search for particular lines from any book then what you will do! every time you will search as per the level/node. If it is the case, how it will be generic function!
May be you are thinking as per Tree Modal! - AlexKarasChampion Level 3Hi Gopal,
Yes, this is possible. Straightforward analogue to the sample provided by ahuja1234 at http://www.geekinterview.com/talk/14-descriptive-programming.html.
You need to create wrapping functions (stubs) that will return tested objects for your (future) application and use methods/properties of the returned objects. - Hi,
Can anyone please tell me how to achieve Descriptive Programming for Web based applications in Test Complete. I have searched lots of site but not getting anything that would be helpful to me. Please let me where can i get it.
thanks - YMinaevStaffHi,
Descriptive Programming
You can address your application objects as described in the "About Working With Application Objects and Controls" help topic.Web based applications in Test Complete
To learn how to perform functional testing of web pages, see the "Testing Web Applications" help topic and those related. - Hi Lukas Krupa,
I tried to use the descriptive programming approach as per you but didn't worked for me. Can you post any working sample code here.
Thanks,
Related Content
- 5 months ago
- 14 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 7 days ago