Forum Discussion
I believe now this summary should be accurate:
✅ The application is running and responsive.
✅ The test successfully interacts with the same item multiple times.
❌ Eventually, the error occurs: "There was an attempt to perform an action on a zero-sized window."
❌ Calling .Refresh() on the process or UI object does not fix it.
✅ The only time the .Refresh() helps is when the test case is restarted and .Refresh() is called twice.
This error often happens when a mapped UI element becomes stale. TestComplete still holds a cached reference, even though the app UI has changed.
🔄 Use Refresh() to update the overall system object tree and ensure TestComplete sees newly created or modified processes and windows.
🔄 Use RefreshMappingInfo() to specifically update the cached object reference for a mapped object or alias, forcing TestComplete to re-evaluate its mapping criteria and find the correct instance of the object.
✅ The recommended way to clear a stale or cached object is to first call .Refresh(), followed by .RefreshMappingInfo() on the relevant mapped parent or control. This combination ensures both the object structure and mapping cache are refreshed.
mappedObject.Refresh(); // Updates the object tree
mappedObject.RefreshMappingInfo(); // Forces re-identification via Name Mapping
💡 Try this retry Pattern for stale UI element
function SafeClick(target) {
const maxRetries = 5;
for (let i = 0; i < maxRetries; i++) {
target.Refresh();
target.RefreshMappingInfo();
Delay(300);
if (target.Exists && target.VisibleOnScreen && target.Enabled && target.Width > 0 && target.Height > 0) {
target.SetFocus();
target.Click();
return;
}
}
Log.Error("Failed to click target after refresh attempts.");
}
🤖 AI-assisted response.
💬 Found this helpful? Click Like to show appreciation.
✅ Issue resolved? Mark as Solution to help others.
The function SafeClick doesn't work. I am still not able to click the object.