Forum Discussion
Hi Hassan,
Thank you for you reply. I tried the following code as you suggested:
function test2()
{
var WA = Sys["Process"]("AXISEL")["WinFormsObject"]("MainForm")["WinFormsObject"]("splitContainer1")["WinFormsObject"]("SplitterPanel", "", 1)["WinFormsObject"]("NavigationBar")["WinFormsObject"]("WorkAreaView")["WinFormsObject"]("TV")["OutlineItem"]("TestComplete Work Area 1*");
WA["Refresh"]();
Delay(1000);
Log["Event"](WA.VisibleOnScreen);
Log["Event"](WA.Enabled);
Log["Event"](WA.Width);
Log["Event"](WA.Height);
WA["WaitProperty"]("VisibleOnScreen","True",2000);
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.
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.
- scot19674 months ago
Champion Level 3
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.
- scot19674 months ago
Champion Level 3
... Would this be "Thinking outside of the box"? π