Forum Discussion
That is interesting, let's recap the problem:
✅ The application is running and responsive.
✅ The test successfully interacts with the same item multiple times.
❌ Eventually, error "There was an attempt to perform an action on a zero-sized window".
❌ Calling .Refresh() on the process/UI object on the first retry does not fix it,
✅ but does fix it on the second attempt.
Now that you have a work around by refreshing twice, lets also consider refreshing the object cache https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/refreshmappinginfo-method.html
The RefreshMappingInfo method clears the cached object reference and searches for the object again. You may need to use this method:
- if the object’s identification properties were changed,
- if the object was recreated in the application,
- if another object matches the mapping criteria,
- before checking if the object exists.
Hi Hassan,
The steps you listed above are correct, just want to clarify one thing method Refresh works on second attempt if I rerun the test case, on first attempt even if I put Refresh twice it doesn't work.
Also RefreshMappingInfo is not available for the object/application I am testing.
- Hassan_Ballan4 months ago
Champion Level 3
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. - hina4 months agoContributor
The function SafeClick doesn't work. I am still not able to click the object.