jose_pita
12 years agoSuper Contributor
10 seconds to find an object.
So, after having to redo all my tests because the developers changed all the structure of our webapp and all the name mapping objects were "Objects not found", I started to use the findChild function on the browser object.
A new problem arised, I put a timer everytime I used the function, usually it takes between 1 and 3 seconds to find the object, not too bad, but on some pages it takes 10 or more seconds...
The thing is, I can't give it a closer parent because it keeps changing. So, besides saving the father to a variable and keep updating it, what else can I do to avoid this situation? TC searches the entire structure before clicking the object, is it possible to make it click the first object it finds?
This is the DOM structure of the app (untitled.png).
This is the code i'm using:
startTimer();
// Using the Find method
var parent= Sys.Browser("iexplore").Page("*");
var celula;
var pro_name = new Array(propertyName,"VisibleOnScreen");
var pro_value = new Array(propertyValue,"True");
if(tab.Exists)
{
celula = parent.FindChild(pro_name ,pro_value ,20);
celula.Click();
}
stopTimer();
A new problem arised, I put a timer everytime I used the function, usually it takes between 1 and 3 seconds to find the object, not too bad, but on some pages it takes 10 or more seconds...
The thing is, I can't give it a closer parent because it keeps changing. So, besides saving the father to a variable and keep updating it, what else can I do to avoid this situation? TC searches the entire structure before clicking the object, is it possible to make it click the first object it finds?
This is the DOM structure of the app (untitled.png).
This is the code i'm using:
startTimer();
// Using the Find method
var parent= Sys.Browser("iexplore").Page("*");
var celula;
var pro_name = new Array(propertyName,"VisibleOnScreen");
var pro_value = new Array(propertyValue,"True");
if(tab.Exists)
{
celula = parent.FindChild(pro_name ,pro_value ,20);
celula.Click();
}
stopTimer();
- Hi Jose,
The best way to decrease that time is using a closer parent, of course. But even if it keeps changing, there's no problem at all, TC will update the object DOM (and if not, you can force it to).
So, even if the object contents change, while you can retrieve it there's no problem at all.
Also, you can try changing the search depth. If you know what depth will always have (I assume there is no way an object moves from depth 5 to 12, for example), set this depth + 1 as search depth, just to make sure:
celula = parent.FindChild(pro_name ,pro_value ,expected_depth + 1);
celula.Click();
You can check my blog, I've written a bit about it.
Hope it helped!