Forum Discussion
Yup... and I agree.
But going back to my original post: "I also can't reliable use a FindChild event as TestComplete does not replay 100% of the time. "
The script will not reliably find the child control every time for me.
I have a page in my IE11 browser:
AnyPage = Sys["Browser"]("iexplore")["Page"](ProjectSuite["Variables"]["ServerURL"]+"/*");
and I need to find the textbox in our floating menu in the old UI:
AnyPage["Table"](1)["Cell"](0, 0)["Panel"](1)["Textbox"]("menuSearch")
or in the new UI:
["Panel"](2)["Nav"]("menu_root")["Panel"](0)["Textbox"]("menu_search_input")
So I'm trying to write a function that checks for the existence of one and then potentially the other... without relying on a variable that says which version of the UI we're running against. (which is how my current implementation gets around this issue)
I know there are plenty of properties that change between these two textboxes. (idStr being the most important). But running the FindChild function on the two textboxes will not reliably replay in TestComplete on each of my pages.
So I was trying to go down to the root of the menu's hierarchy (table vs. panel and see if I could get it to work that way)... and I'm not having much luck that way either.
I'm open to suggestions. :)
Can you share an example of your attempt to use FindChild that is not working? I don't think the problem is necessarily in FindChild, but perhaps simply in finding the correct properties to work with.
- tristaanogre7 years agoEsteemed Contributor
Generally speaking.... start with a common parent object on both UI's... let's called it PanelX. So, you could do your code like this (I'm using a JavaScript syntax but, technically, this should work fine even in your C#Script since it is, under the covers, just JScript with support for C# Syntax).
var myObject = PanelX.FindChildEx(['ObjectType','idStr'],['Textbox','menuSearch'], 5, true, 10000) if (myObject.Exists) { Log.Message('Must be using the old UI'); } else { myObject = PanelX.FindChildEx(['ObjectType','idStr'],['Textbox','menu_search_input'], 5, true, 10000); if (myObject.Exists){ Log.Message('Must be using the new UI'); } else { Log.Warning('Could not find the object in either UI pattern'); } }
Basically... search for it at a depth of 5 (this is assuming that PanelX is at most 5 ancestors above the desired child object) using the old UI idStr and continue pinging it for 10 seconds until either the object is found or the time out is reached. If it is not found there, search using the new idStr and continue pinging for 10 seconds. If it's not found there, log a warning, otherwise, myObject is now the desired object.
- bo_roop7 years agoContributor
PropArray = new Array("ObjectType", "idStr", "ObjectIdentifier", "className"); ValuesArray = new Array("Textbox", "menuSearch", "menuSearch", "menuSearchReady"); // Find the cell where the link/button resides var textbox = AnyPage["Find"](PropArray, ValuesArray, 1000);
This didn't reliably replay, so we decided to drop the ObjectIdentifier & className.
PropArray = new Array("ObjectType", "idStr"); ValuesArray = new Array("Textbox", "menu-search-input"); // Find the cell where the link/button resides var textbox = AnyPage["Find"](PropArray, ValuesArray, 1000);
This didn't replay 100% of the time either... probably 95-98% of the time, but it was an improvement over the 85-90% we started with.
- tristaanogre7 years agoEsteemed Contributor
Try changing from FindChild to FindChildEx with an additional parameter for timeout (see my example above)
- tristaanogre7 years agoEsteemed Contributor
Note, also, that before I do anything with the object I'm searching for, I always check the "Exists" property... FindChild and FindChildEx will ALWAYS return an object with that property... if it doesn't find what you're looking for, that "stub" object has an Exists property with a value of "false" so this is an easy way to check if you found what you're looking for without TestComplete complaining about "Object not found" or "cannot call a method on undefined" or something like that.
- bo_roop7 years agoContributor
FindChildEx appears to be working fine... now to go send it off through our array of Virtual Machines to see if it's working better there too.
Thanks!
Hopefully we won't have to revisit this on Monday. :)
Related Content
Recent Discussions
- 3 hours agoashly