There was an attempt to perform an action on a zero-sized window

Originally posted by hina on August 27, 2025

Hi,

I am working with Desktop application and I am trying to click on an object. I can click on the same object multiple times until I start receiving the error message: “There was an attempt to perform an action on a zero-sized window”. I have tried few things to resolve this issue but nothing works:

  1. I have tried calling the Refresh method before clicking the object
  2. I have tried putting a delay before clicking the object
  3. I have checked the height and width of the object, it is not zero and is visible on screen

The only thing that work is when restart the application and try to click the same object, it doesn’t give me that error until I click the same object multiple times I start receiving the same error message again.

What can I do to stop receiving this error?

Thanks,

Hina

Originally posted by scot1967 on August 27, 2025

Hello hina,

I thought you were right to try a delay. I did a quick community search and found 2 related solved issues. Could you post a code snip? Are you scripting or Keyword testing?

Help with “Zero-sized Window” error? | SmartBear Community
There was an attempt to perform an action on zero sized window | SmartBear Community

Another idea is to verify the object state or insert a waitproperty method call.

WaitProperty Method:
https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/waitproperty-method.html

… If you find my posts helpful drop me a like! :+1: Be sure to mark or post the solution to help others out and/or to credit the one who helped you. :smiling_face_with_sunglasses:

Originally posted by scot1967 on August 27, 2025

P.S. I would check Focusable, IsFocused, IsEnabled, Visible, VisibleOnScreen, IsVisible, Visibility. One of these is likely being toggled between click actions.

Originally posted by rraghvani on August 28, 2025

When you click on the object, does another UI appear, similar to a drop down combo box?

Drop down showing items Blue and Green

Originally posted by hina on August 28, 2025

Hi scot1967,

Thank you for your reply. Here is my code:

function test()
{
var WA = Sys"Process"“WinFormsObject”“WinFormsObject”[“WinFormsObject”](“SplitterPanel”, “”, 1)“WinFormsObject”“WinFormsObject”“WinFormsObject”[“OutlineItem”](“TestComplete Work Area 1*”);
WA"Refresh";
Delay(1000);

WA"WaitProperty";

WA"Click";
}

I tried the WaitProperty method, it works sometimes and sometimes it doesn’t.

Originally posted by hina on August 28, 2025

Hi rraghvani,

Thank you for your reply. Below is my UI:

I am trying to click “TestComplete Work Area 1”, that’s when I see the error I reported. When I click “TestComplete Work Area 1”, the Dataset list on right side shows up.

Originally posted by rraghvani on August 28, 2025

I’m assuming the Datasets is not populated until the Work Areas item is selected first? If that is the case, then you need to wait for the child item Datasets object to exist, before proceeding to the next step.

If you use the Object Browser, you should be able to see the behaviour of how your object is created.

I’m using Browser App as an example - you have the following item .Panel(6).Panel(0).Button(“dropdownMenuButton”) which represents the button ‘Dropdown button’. However, the child item .Panel(6).Panel(0).Panel(0) does not exist yet (shown in red).When you click on the button ‘Dropdown button’, the child item .Panel(6).Panel(0).Panel(0) is then created (shown in blue). You can then access the object afterwards.

Use the appropriate WaitNNN methods to wait for the child object to appear first.

Originally posted by Hassan_Ballan on August 28, 2025

The error indicates that the object wasn’t ready for interaction at the time the action was attempted. The test log often includes a screenshot, which can provide helpful visual context on the state of the UI at the failure point. https://support.smartbear.com/testcomplete/docs/testing-with/running/handling-errors/searching-for-cause.html

Here are a few targeted suggestions:

  1. Use VisibleOnScreen and Enabled Together along with Width and Height
if (obj.VisibleOnScreen && obj.Enabled && obj.Width > 0 && obj.Height > 0) {
    obj.Click();
} else {
    Log.Error("Object is not intractable at this time.");
}

You can also configure https://support.smartbear.com/testcomplete/docs/working-with/managing-projects/properties/visualizer.html or https://support.smartbear.com/testcomplete/docs/reference/test-objects/controls/misc/options/index.html Visualizer to capture object info

// Set the option to "Capture images and test object info"
Options.Visualizer.CollectMode = vcmImg;

:robot: AI-assisted response.
:speech_balloon: Found the answer helpful? Give it a Kudos by clicking Like!
:white_check_mark: Got your issue resolved? Click Mark as Solution so others can find it quickly.

Originally posted by scot1967 on August 28, 2025

Hello again,

Since this is happening only on repeated click attempts I would log the related states of the WA object just prior to clicking the object to see if there are any differences between working and not. It may give you another useful error if it is unable to log the state of the object.

I would check Focusable, IsFocused, IsEnabled, Visible, VisibleOnScreen, IsVisible, Visibility. One of these is likely being toggled between click actions.

Originally posted by scot1967 on August 28, 2025

… Some of these states may not apply to your object and there may be others you can check I have not listed here. The delays seem to be needed in the solved cases to allow time for object state changes or creation.

Originally posted by hina on August 29, 2025

Hi Hassan,

Thank you for you reply. I tried the following code as you suggested:

function test2()
{
var WA = Sys"Process"“WinFormsObject”“WinFormsObject”[“WinFormsObject”](“SplitterPanel”, “”, 1)“WinFormsObject”“WinFormsObject”“WinFormsObject”[“OutlineItem”](“TestComplete Work Area 1*”);
WA"Refresh";
Delay(1000);

Log"Event";
Log"Event";
Log"Event";
Log"Event";

WA"WaitProperty";

if (WA.VisibleOnScreen && WA.Enabled && WA.Width > 0 && WA.Height > 0)
WA.Click();
else
Log.Error(“Object is not interactable at this time.”);

}

So at the time of clicking the object, the width and height is 0 and the property VisibleOnScreen is False, even though I can see the object on screen. After using Refresh method on the object multiple times, I can click the object. I tried using WaitProperty method as shown above in the code, but no use.

Originally posted by Hassan_Ballan on August 29, 2025

It looks like the object isn’t fully initialized when TestComplete tries to interact with it, even though it’s visually present. This is common with complex WinForms UIs.

Try using a polling loop with Refresh() and short delays, and also check parent container visibility. If the control is virtualized or delayed in rendering, this should help you synchronize interaction more reliably.

Also consider using WaitChild() or FindChild() to ensure dynamic readiness, and try SetFocus() before clicking.

// 1. Use WaitAliasChild or WaitChild Instead of Static Object References
var WA = Sys.Process("AXISEL")
  .WinFormsObject("MainForm")
  .WinFormsObject("splitContainer1")
  .WinFormsObject("SplitterPanel", "", 1)
  .WinFormsObject("NavigationBar")
  .WinFormsObject("WorkAreaView")
  .WinFormsObject("TV")
  .WaitChild("OutlineItem", 5000);

if (WA.Exists) {
  WA.Refresh();
  Delay(1000);
  // ...
}

// 2. Loop Until the Object Is Interactable
var maxTries = 10;
var success = false;

for (var i = 0; i < maxTries; i++) {
  WA.Refresh();
  Delay(500);

  if (WA.VisibleOnScreen && WA.Enabled && WA.Width > 0 && WA.Height > 0) {
    success = true;
    break;
  }
}

if (success)
  WA.Click();
else
  Log.Error("Object is still not interactable after multiple attempts.");

// 3. Check for Parent Container Visibility
var container = Sys.Process("AXISEL")
  .WinFormsObject("MainForm")
  .WinFormsObject("splitContainer1")
  .WinFormsObject("SplitterPanel", "", 1)
  .WinFormsObject("NavigationBar");

Log.Message("Container visibility: " + container.VisibleOnScreen);

// 4. Use SetFocus() Before Interaction
WA.SetFocus();
Delay(500);
WA.Click();

In some WinForms apps (especially with custom or third-party controls), elements like tree views use virtualization — meaning TestComplete sees the node only when it’s scrolled into view or selected.

You might need to scroll or expand parent nodes, and use keyboard navigation if mouse-based visibility fails.

Originally posted by scot1967 on August 29, 2025

Yep, good thought. I too have seen instances where the state of the parent object affects the accessibility of the child objects. I have had drop downs built like this where they were embedded in a TreeView or other such odd or complex object. The parent would lose focus and game over.

Originally posted by scot1967 on August 29, 2025

… Would this be “Thinking outside of the box”? :wink:

Originally posted by scot1967 on August 29, 2025

A screen shot of the object tree section you are working with may be helpful. Expand it out to the child object you are trying to work with and include any relevant details of the objects.

I once had to deal with an object that was a TextBlock until it was clicked on. Then it became a TextBox I could add data in. The manual GUI tests were fine but TC had to be coded to click the ‘Block’ and wait for the ‘Box’ A super big pain to discover and code around.

Originally posted by rraghvani on September 02, 2025

hina​ have you tried using the appropriate WaitNNN methods to wait for the child objectto to be created?

From what your have mentioned with regards to property values, it seems like your object is not created. Therefore, you can not check the property values yet.

Originally posted by hina on September 02, 2025

Hi rraghvani,

Yes, I have tried WaitChild method, but no luck. The only thing that is working everytime is when I restart the application I am working with.

Originally posted by rraghvani on September 02, 2025

If you use the Object Browser (not Object Spy), is there any indication as to when the child object is created?

Are you able to post a picture of the Object Browser, before and after object is created (similar to my example)?

Originally posted by hina on September 02, 2025

I am posting a screenshot of the Object Browser, the highlighted object is what I am trying to click:

This object is always visible physically, as you can see in the screenshot the object is visible but still the Height and Width is 0. I am also including the screenshot of the object browser after restarting the application, where Height and Width is not 0 and I am able to click the object:

Originally posted by Hassan_Ballan on September 02, 2025

Notice also the ControlIndex and ControlIndexGroup are “-1”. It looks like the UI element is being destroyed and never properly recreated, or Memory corruption or rendering issues.

What happens when you try code refresh, or Object Browser panel GUI refresh

Sys.Refresh(); // Refresh process list
Sys.Process("MyApp").Refresh(); // Refresh UI tree inside app