Ask a Question

getting objects via recurssion

sivakarthik
Contributor

getting objects via recurssion

Hello Community members,

 

I just had a thought acquiriung objects via recurssion. is it possible to do that with test complete ?

 

for example 

obj name texts - function for storing and returning the texts

then I would like to do it recurssively is it possible to do that ?

 

any ideas ? please let me know ?

 

Thanks and Regards

SivaKartheek Sreeram

12 REPLIES 12
AlexKaras
Community Hero

Hi,

 

> then I would like to do it recurssively is it possible to do that ?

Recursive code call is a feature of scripting language and thus it definitely can be done in TestComplete.

Code template is like this:

function main()

{

  value = RecursiveFunction(<param>);

}

 

function RecursiveFunction(<param>)

{

  param1 = <ModifyParamAsNeeded(param)>;

  // check if recursion should continue

  if (<ShouldContinueWithRecursion(param)>)

    return RecursiveFunction(<param1>);

  else

    return <param1>;

}

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================

Dear AlexKaras,

 

Thank you for your reply, I know about the concept of recurssion and how  to do it also but my question is,

 

eg. The below is the object 

Aliases.Process().VCLObject(text).VClObject(text1).VCLObject(text2)

 

is it possible to do above object mapping via recurssion ?

 

function for texts

 

recursion function returs VCLObject(texts)

 

thanks and regards

SivaKartheek Sreeram

 

You're already accessing them via Aliases... why would you need to use recursion?  Simply map the components you need to use.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Hi Tristaanogre,

 

thanks, Actually for some components the mapping is too long and some of the elements have the same mapping and at the end of the objects are different so I thought of recurssion.

 

thanks and regards

SivaKartheek Sreeram 

Hi,

 

The beauty of Aliases is that their tree can be reorganized to be less deep and more convenient for use. This is described here: https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/abou.... Have you considered this option? Does it fit your needs?

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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 Heroes]
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 Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
tristaanogre
Esteemed Contributor

What @AlexKaras said... that's the whole point of Aliases... you MAP the whole thing, but then you use the Aliases to "telescope" the objects down to what is strictly necessary for your code.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

 

Dear tristaanogre,

 

I have understood the concept of Aliasse but acutally what I am trying to do is,

In each bar item, there is a grid and I would like to test in that grid.

the grid mapping examples like this:

Aliases.process().VCLObject(txt1).VCLObject(text2).VCLObject(text3)...VCLObj(text4).VCLObject(text5)

Aliases.Process().VCLObject(txt1).VCLObject(text2).VCLObject(text10)...VCLObj(text4).VCLObject(text5)

Aliases.Process().VCLObject(txt1).VCLObject(text2).VCLObject(text10)...VCLObj(tex16).VCLObject(text5)

 

so I would like iterate till the cond if cond satisfy take the text 10 like that

 

I would like to 

did you get my point now ?

thanks and Regards

SivaKartheek sreeram

Again, to be clear... you haven't mapped ANYTHING.  Terminology matters. 🙂

So... what I would suggest... map everything up to a point where there is a common parent.  Then use the "FindAllChildren" method on that parent to search for and return a collection of all the desired child objects.  That is usually returned as an array.  You can then do a for loop through that array and process each item individually.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

hi Tristaanogre,

 

At first, even I have used just like you said but, with that I have to define so many times. 

thats why I thought of recurssion but now I am implementing in different way.

At first storing those texts values in a dictonary and list. If condition satisfies thenI will use that text into that VCLObject. 

With that I don't have to redefine again and agin and now its works fine

 

thanks and Regards

SivaKartheek Sreeram

cancel
Showing results for 
Search instead for 
Did you mean: