Ask a Question

Can we do descriptive programming

gopalmalu
Contributor

Can we do descriptive programming

Hi,



Can we do scripting (descriptive programming) with TC if application is not developed ?



Thanks,

Gopal
15 REPLIES 15
AlexKaras
Champion Level 2

Hi 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.
Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
manavendra
Not applicable

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
YMinaev
Staff

Hi,



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.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
prakashk
Occasional Contributor

Hi,



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_luke
Occasional Contributor

Hi,



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 🙂
aditya_shrivast
Not applicable

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,
Ravik
Super Contributor

Hi 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.

                            
SriniG
Contributor

Yes we can! Try this one



Function Descript()




   Set pg=Sys.Browser("iexplore").Page("*")


   NameProperty = Array("textContent","outerText","Id","tagName") 


   ValueProperty = Array(strPropVal1,strPropVal2,strPropVal3,strPropVal4)


   Set obj=pg.FindAllChildren(NameProperty,ValueProperty,9999999,True)


   obj.Method  



End Function



Based on your requirement enter the Name property and their Property value into array.



Thank you,

Srini.



 

Colin_McCrae
Community Hero

Eh?



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.
cancel
Showing results for 
Search instead for 
Did you mean: