Forum Discussion

Piyush_77's avatar
Piyush_77
Occasional Contributor
7 years ago
Solved

JScript runtime error . This Operation was canceled because the method invoke timeout has expired.

Hello People,

 

I have 2 functions. First one is for the Toolbar function for the software desktop application and In second function I have used that Toolbar function. Currently , My aim is to get output for the second function. So whenever I call the Toolbar function in my Second function it generates Error like"JScript runtime error . This Operation was canceled because the method invoke timeout has expired."

 

Here is My Both Functions;

 

function GetToolBarItemStatus(stringToolTipName){
var currentUIRootObject = ObjectUIMap["GetCurrentRootObject"]()
objectToolBarMain = currentUIRootObject["MainForm"]["WinFormsObject"]("_topSandBarDock")["FindChild"]("Index", "2", 0, true)
if (objectToolBarMain.Exists==true)
{

for(integerItemIndex = 0; integerItemIndex < objectToolBarMain.Items.Count; integerItemIndex++)
{

if(aqString.Find(objectToolBarMain.Items.Item(integerItemIndex).ToolTipText,stringToolTipName,0,true) != -1) // Error in this line
{
objectItem = objectToolBarMain.Items.Item(integerItemIndex);
break;
}





for(i=0; i<11 ;i++)
{
if(objectItem["Enabled"]==true)
{
return true;
}
Delay(1000)
if(i == 10)
{
return false;
}
}

}
else{
Log["Warning"]("Object Tool Bar not found!")
}
return false

}

 

"2nd function :

 

function LoginWithParameter(){

Log["Message"]("loging in for the first time.")
// ToolBar["SelectToolBarItem"](objectToolBarMain,"Login");
if(GetToolBarItemStatus("Login (Alt+F8)")==true){
currentUIRootObject["MainForm"]["Keys"]("~[F8]")
Delay(1000)
}
else{
Log["Error"]("Login button in the tool bar is not enabled","",pmNormal,pmNormal,currentUIRootObject["MainForm"])
}


do
{


// Cold start of the Controller


objectColdStartWindow = currentUIRootObject["WaitWindow"]("#32770","SoMachine", -1, 5000)

if (objectColdStartWindow.Exists){
objectColdStartWindowText = objectColdStartWindow["FindChild"](new Array("WndClass","Index"),new Array("Static","2"),0,true) 
if (objectColdStartWindowText["Exists"]){
stringColdWindowText=objectColdStartWindowText["WndCaption"]
Log["Message"](stringColdWindowText)
if(aqString["Find"](stringColdWindowText, "a cold start must be performed", 0 ,false)!=-1){
objectJaButton = objectColdStartWindow["FindChild"]("WndCaption", "&Ja",0, true)
Log["Checkpoint"]("Cold start Window", "",pmNormal,pmNormal,objectColdStartWindow)
objectJaButton.Click()
}
}
}


//Delay(50000 )
boolStatusLogout=GetToolBarItemStatus("Logout (Ctrl+F8)")
boolStatusRun=GetToolBarItemStatus("Start (F5)")
boolStatusStop=GetToolBarItemStatus("Logout (Shift+F8)")
} while (boolStatusLogout==false&&(boolStatusRun==false||boolStatusStop==false));
}

 

With Delay it works fine but I dont want to put the delay!! Is there any alternative Solution avilable??

 

 

  • Instead of a hardcoded delay, a better option would be to use some sort of "Wait" method (search in TestComplete help for WaitNNN) to wait for the application to be in a state to move on with the tests.  You can wait for a property change, for an object to exist, etc.  You can write custom wait code to wait for an SQL data record to be altered.  Research these topics and see what you can come up with.

2 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Instead of a hardcoded delay, a better option would be to use some sort of "Wait" method (search in TestComplete help for WaitNNN) to wait for the application to be in a state to move on with the tests.  You can wait for a property change, for an object to exist, etc.  You can write custom wait code to wait for an SQL data record to be altered.  Research these topics and see what you can come up with.

    • Piyush_77's avatar
      Piyush_77
      Occasional Contributor

      Thank you So much for the suggestion and Reply!!:smileyhappy: