Forum Discussion

sudhir_optima's avatar
sudhir_optima
Contributor
14 years ago

Error when play the script

We have create a Function as below.


function OpenWorkbook(WB)


{


  //Moves the mouse cursor to the specified item and then simulates a single click.


  Aliases.QBIS.MainMirandaConsole.rbnBarMain.ClickItem("ApplicationButton|Open");


  //Enters text in the text editor.


  Aliases.QBIS.dlgOpen.ComboBoxEx32.SetText(WB);


  //Aliases.QBIS.dlgOpen.DUIViewWndClassName.DirectUIHWND.FloatNotifySink.ComboBox.Edit.SetText(WB);


  //Simulates a left-button single click in a window or control as specified (relative position, shift keys).


  Aliases.QBIS.dlgOpen.btnOpen.ClickButton();  


 When Played the script it displayed following error.


An error occurred while calling the "ClickItem" method or property of the "rbnBarMain" object.

The object or one of its parent objects does not exist.


Tested Object















Alias:



Aliases.QBIS.MainMirandaConsole.rbnBarMain



Mapping item:



NameMapping.Sys.QBIS.MainMirandaConsole.rbnBarMain




Missing Object















Alias:



Aliases.QBIS.MainMirandaConsole



Mapping item:



NameMapping.Sys.QBIS.MainMirandaConsole





Please find the screen shot of the Maped Object, Aliases, and Object browser. Everything seems ok, still getting above error.

2 Replies

  • I debug it and found that it might be synchronization issues.I run the script routing individually and the mention error does not appear.

    1.Install the aplication

    2.Open the Workbok.



    My Application takes time to get vsisible when we invoke it.That is why its giving the error because it might try to perform action defined in routine 2.



    But now the problem is in Routine 2.It passed without performing the action mention in the Open The Workbook routine.



    Its able to click on Open button as mention in below script.

    Aliases.QBIS.MainMirandaConsole.rbnBarMain.ClickItem("ApplicationButton|Open");



    But does not perfrom any action with below script.




    Aliases.QBIS.dlgOpen.ComboBoxEx32.SetText(WB)



    I guess this is beacuse of ProjectSuite Variable. Are they are tempoary for the Step Execution.

    I mean I have defined it in first line of script.In second line i am calling this variable.

    If I Run the first line by selecting > Run Selected option it runs successfully.

    But then If I run the second line > Run Selected option it doen not recall the variable.



    Is this mean the variable is temporary for the Single Run ?
  • Hi Sudhir,



    My Application takes time to get vsisible when we invoke it.That is why its giving the error because it might try to perform action defined in routine 2.
    You can increase the timeout within which TestComplete is waiting for objects to appear using the Tools > Current Project Properties > Playback > Auto-wait timeout, ms option. The default value of 10 sec seems to be insufficient for your tested app. For heavy .NET applications, we recommend setting this option to at least 60000 ms (that is, 60 sec).



    I mean I have defined it in first line of script.In second line i am calling this variable.

    If I Run the first line by selecting > Run Selected option it runs successfully.

    But then If I run the second line > Run Selected option it doen not recall the variable.



    Is this mean the variable is temporary for the Single Run ?
    I guess, your variable is defined as temporary, that's why, it doesn't preserve values between test runs. To use it in the scenario you described, you'll need to redefine the variable as persistent. To do this:

    * Right-click your project suite in Project Explorer and select Edit > Variables from the context menu.

    * Note down the name, type and default value of the variable in the Temporary Variables table. Then, delete this variable.

    * Right-click the Persistent Variables table, select New Item from the context menu and create a variable with the same name, type and default value.

    Now, the variable will keep the value assigned during the previous test run.





    //Enters text in the text editor.

    Aliases.QBIS.dlgOpen.ComboBoxEx32.SetText(WB);

    //Aliases.QBIS.dlgOpen.DUIViewWndClassName.DirectUIHWND.FloatNotifySink.ComboBox.Edit.SetText(WB);

    //Simulates a left-button single click in a window or control as specified (relative position, shift keys).

    Aliases.QBIS.dlgOpen.btnOpen.ClickButton();

    By the way, I'd recommend using the specialized OpenFile method to automate the Open File dialog, e.g.:

    The Open File dialog has different GUI implementations in different Windows versions, and the OpenFile method is specially designed to help you avoid possible playback issues caused by these differences.