Unable to find button object
Hi,
I have to click the Yes button in order to load the application completely. The attached pop-up window appears when I open a file using TestComplete. The pop-up window appears after some time when the product is launched. Here is the code I have written to click the Yes button. I am trying to wait for that button until it appears on the screen. First, I used the Find method, and then I used FindChildEx. The code is working intermittently. It's not able to find the button always. Can you please tell me what I need to change or is there a simple way to click the button as soon as it appears?
//Using the Find method
var counter = 0;
p = NameMapping.Sys.Process("ORD");
while(true)
{
Delay(3000);
if(counter > 100)
{
throw new error("Compact database did not appear")
}
var btnYes = p.Find("WndCaption", "&Yes", 500);
if(btnYes.Exists)
{
btnYes.Click();
break;
}
counter++;
}
//Using the FindChildEx method
Delay(5000)
p = Sys.Process("ORD")
if(p.Exists)
{
var yesBtn = p.FindChildEx("WndCaption", "&Yes", 10, true, 1000);
var counter = 1;
while(!yesBtn.Exists)
{
Delay(2000);
yesBtn = p.FindChildEx("WndCaption", "&Yes", 10, true, 1000);
counter++;
if(counter > 50)
{
break;
}
if(yesBtn.Exists)
{
yesBtn.ClickButton();
break;
}
}