I cannot use mapping because I need cross-browser code and the pages are too dynamic to map reliably.
I've also learned timing is a critical issue in the search for ExtJS items in the object tree. There appears to be two problems:
1) The page has to completely redrawn after a page request caused by a screen button click.
2) After the page is drawn, I cannot serach the object tree successfully until the object tree has been refreshed manually. The "simple" pages I'm testing right now have between 400 and 800 items per page while there are only 5 to 10 controls on the page.
Although this isn't the best place to put the delays and refresh, this way I don't have to think about whether I need to do it or not and just accept the 2 seconds overhead per search.
Example:
MyItem = Item_LocateInPage(BrowserProcess, "innerHTML", "Cancel");
if(MyItem != null) {MyItem.Click();}
function Item_LocateInPage(TREE_MODEL_OBJECT, PropertyType ,SearchText)
{
Log.Message("Item_LocateInPage: " + PropertyType + " " + "\'" + SearchText + "\'")
var obj = null;
Delay(1500); // Wait for page to draw
TREE_MODEL_OBJECT.Refresh();
Delay(500); // Wait for object model to refresh
if(!TREE_MODEL_OBJECT.ChildCount || TREE_MODEL_OBJECT.ChildCount == undefined)
{Log.Warning("No " + TREE_MODEL_OBJECT + " Children Detected in search"); return null}
Log.Message("Searching " + TREE_MODEL_OBJECT.ChildCount + " children...");
if(PropertyType == "idStr")
var obj = TREE_MODEL_OBJECT.FindChild("idStr", SearchText, 100);
if(PropertyType == "outerText")
var obj = TREE_MODEL_OBJECT.FindChild("outerText", SearchText, 100);
if(PropertyType == "Name")
var obj = TREE_MODEL_OBJECT.FindChild("Name", SearchText, 100);
if(PropertyType == "NodeName")
var obj = TREE_MODEL_OBJECT.FindChild("NodeName", SearchText, 100);
if(PropertyType == "value")
var obj = TREE_MODEL_OBJECT.FindChild("value", SearchText, 100);
if(PropertyType == "textContent")
var obj = TREE_MODEL_OBJECT.FindChild("textContent", SearchText, 100);
if(PropertyType == "innerHTML")
var obj = TREE_MODEL_OBJECT.FindChild("innerHTML", SearchText, 100);
if ((obj == null) || (false == obj.Exists))
{
Log.Warning("Not Found.");
return null;
}
else
return obj;
}
-Pv-