Ask a Question

Help! lightweight find method for flex/flash application needed.

SOLVED
Antonio_Haynes
Contributor

Help! lightweight find method for flex/flash application needed.

Hello,
 I have implimented a basic find method to locate objects in my tested application. 

Method Below:

 

function Get_Control(PropName, PropVal){
 //Creates arrays of property names and values
 propArray = PropName.split(",");
 valuesArray = PropVal.split(",");

 // Searches for the control
 var p = Project.Variables.Process;
 // Depth at 1000 because we do not know where the control might be.
 Project.Variables.Control = p.Find(propArray, valuesArray, 1000);

 // Processes the search results
 if (Project.Variables.Control.Exists){
  Log.Message(Project.Variables.Control.Name);
 }
 else{
  if(!Project.Variables.Optional){
   Log.Message("Failed to Identify an object by the property value specified.", PropName + " " + PropVal)
   Log.Error("The object was not found.");
  }
  else{
   Project.Variables.MoveToNextStep = true;
  }
 }
}

 

This method works woderfully when i am in the login screen of my application wich has maybe 20 controls to sort through.
However once logged into my application there are thousands of controls to sort through and i have seen up to 3 minute wait times before a control is found, if i am lucky.
One other thing that happens when trying to find a control using this method, there is a constant growth in memory usage on my machine between my browser and Test Complete. I have tried finding ways to disable caching of objects during playback and set my name mapping to Do not store Code Completion data, wich helped a little on the memory usage.
I am running Windows 7 64bit OS with 6GB ram and after disabling store code completion data, im left with about 50 mb ram by the time my control is found now.
Test Complete runs at about 200,000 kb ram during normal use and my Fire fox is about 250,000kb during normal use with TC.
I have watch these processes reach the millions while executing the find operation and even crashed TC a few times.

I hope to use a method like this to find the control I intend to work with, but taking anything more than a few seconds to find a control is not acceptable when there may be hundreds of controls needed in a single test.
Please help me on this, I need something fast and lightwieght enough to not max my proccessor.
This method is the heart of my project, if i can't effectivly find my controls, then i don't have anything to work with.
I would also like to avoid name mapping as our developers do daily releases and while the properties of the controls users can see on the page don't normally change, we see alot of containers and wrappers that are dynamically generated and even some containers that do not exist between browsers. Name mapping for this particular test environment has created a nightmare for my team and become more work than i feel we can keep up with, this project is an attempt to resovle some of those issues.


The tested application I am working with is a flex/flash application and my tests must be able to execute against IE, FireFox, and Chrome.

Thanks, and feel free to ask for more information if i've left something out.

17 REPLIES 17

Alex,
 yes your solution is exactly what i plan to do, although im am trying to build an excuting script using test complete and run my steps off of an excel file. So i want to stay away from using name mapped items inside the project. I need to be able to hand a parent control using a column in my xls to help narrow the search. Unfortunalty I can think of a number of ways that this could cause issues in playback. So any tips and tricks i can use would be helpful.
In order to call the parent object without a name mapping I think i'm going to have to use the full name of the control.
I'm not sure off the top of my head if i am able to use wildcards in the full name of an object in test complete, if i can that would help keep scripts from breaking when something in the full name has changed.

 

so my executing script might look something like

 

minus the hard coded string πŸ™‚


var parent = Project.Variable.Process + Project.Variable.TestItem("Parent Object Full Name Minus Sys.Browser().Page()");

parent.Find(propNameArray, propValArray, depth);

 

currently my process name is built off the browser and evironment of my tested application specified to test against 
so it looks like 

Sys.Browser(browser).Page(url);

 

so i guess the question now is would something like this work when refrencing the full name of the parent.
Sys.Browser(browser).Page(url).object("myobj*").object("m?obj").Find(propArray,valArray,depth);

I hope that makes sense πŸ˜› sorry its been a long day already.

Thanks

Ryan
 Awesome! I'm Going to try this right now XD
 Thanks, Its much cleaner this time to.

Sure, just note I did not include the second matchproperty function because I made no changes to that. πŸ™‚


''-Praise the sun and Give Kudos.''

Ya, I noticed the missing function πŸ˜› 

Two things:
Have you run a speed comparison between your function utilizing testcompletes find all method and testcompletes find method? If your showing faster times with your method I would be interested in seeing those results as it may suggest that I have an issue elsewhere with my machine.

Also when utilizing the RegEx i recieve an error when the property value looks like "*(1718-000-2013)"
Testcomplete supports the utilization of the "*" at the start of the string yet RegEx would need to have the string reversed and the "*" placed at the end of the string.

Still regardless of which method I have tried, I still find that I need to define closer parent than just the process itself.

I am working on difining this solution in my project still.

Thanks.

 

P.S. I'm not a regex master!

Q: "Have you run a speed comparison between your function utilizing testcompletes find all method and testcompletes find method?"

A: Negative. I assume the built in method is inefficient, but would be happy to be proven wrong.

 

Q: "Testcomplete supports the utilization of the "*" at the start of the string yet RegEx would need to have the string reversed and the "*" placed at the end of the string."

 

A: As my original code notes say ".*" is the same as TestComplete's "*" wildcard and ".?" is the same as TestComplete's "?" wildcard. Regular Expression Syntax

[Edit] added example corrected regex syntax

Ex: ".*myForm.*" same as TC "*myForm*" matches "WinFormsObject("myForm")" and "WinFormsObject("myForm", 2)"

Ex2: "my.?orm" same as TC "*my?orm*" matches "myZorm" and "myorm" 

 

Q: "Still regardless of which method I have tried, I still find that I need to define closer parent than just the process itself."

A: I agree. You should at least limit your search to the page object. However if you are having to then specify a panel or other parent object you aren't exactly achieving a "dynamic" search/find function because it requires prior knowledge of the heirarchy, beyond the page/browser and some generic name or text to find, and leaves you just as vulnerable to hierarchical changes that break your tests.


''-Praise the sun and Give Kudos.''

However if you are having to then specify a panel or other parent object you aren't exactly achieving a "dynamic" search/find function because it requires prior knowledge of the heirarchy, beyond the page/browser and some generic name or text to find, and leaves you just as vulnerable to hierarchical changes that break your tests.

 

-- Agreed, But im not sure what to do testcompletes findall method and find method is the hang up, this is where the performance suffers. Short of finding a way to find controls without using these methods, idk what else to do.

It would be nice to get some feedback from smart bear for these methods and maybe why the caching is doing this, maybe how to disable or clear it and some comment as to maybe how to increase speed when searching through so many objects.

I will say that both of our methods would work against smaller tested apps. πŸ™‚

As a thought i could store the array from the findall in your method and try to find controls from that array and re-execute the findall when we fail to identify an object from the stored array... this would reduce the number of times the find all had to execute and keep us from the heafty wait times and reduce the memory used during testing ... i still dont think its going to be a real solution to the issue though.

also i wounder if we could check controls in our array for child controls and find all children.

Just to follow up with this thread using the browser.find method is working great for me now .... i have managed to remove the name mapping and the tested applications from my project entirely after wich i no longer have any issue with memory i find my controls based on property name/value pairs and im able to pass any process as a tested process and then begin mapping controls using my methods this has opened a great platform for creating automated tests against any platform. I'm in no way trying to play down the name mapping and tested applications included with test complete but i find that this method is much more suitable to automating in my current environment. Thanks for the input in helping me toward my solution!

cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β