Using ControlID for More Stable Desktop UI Tests in TestComplete
Hi SmartBear Team,
Weโre currently working on improving the stability and maintainability of our automated desktop tests using TestComplete for our application, OpenTAS. To reduce object recognition issues and make our tests more robust, weโre considering implementing unique ControlIDs (or similar identifiers like AutomationId) across the UI. How does TestComplete support using ControlID for identifying desktop UI elements?
We tried to interact by using the testcomplete documentation info but it didn't work (see below)
Best regards,
Mustafa
Button Full path= Sys.Process("OpenTAS").WinFormsObject("frm5101Main").WinFormsObject("ImplicoDocumentsHost", "", 1).WinFormsObject("DocumentContainer", "").WinFormsObject("DockPanelForMdi", "PRE-Release - 621 - Service Order").WinFormsObject("_Container").WinFormsObject("Form0621XCustomerOrder").WinFormsObject("actionBar").WinFormsObject("tableLayoutPanelHorizontal").WinFormsObject("ActionBarButtonControl", "", 3).WinFormsObject("btnBack")
The way how I tried to click but didn't work:
// btn control ID = 1511736
function ClickButtonByControlId()
{
var app = Sys.Process("OpenTAS");
var win = app.WinFormsObject("frm5101Main", "*", 1);
var btn = win.FindChild("ControlId", 1511736, 1); // Example ID
if (btn.Exists)
btn.Click();
else
Log.Error("Button not found.");
}
Hi, Yes TestComplete supports what you are doing very well. This is my preferred method of object recognition. Have you tried increasing your search depth to 10 or 12? It looks like your target object is several layers deep from the parent you have specified. To further define your target multiple properties and values can be used in an array format.
TestObj.FindChild(PropNames, PropValues, Depth, RefreshTree)
... If you find my posts helpful drop me a like! ๐ Be sure to mark the best answer if you get one to help others out and to credit the one who helped you. ๐