Forum Discussion

jane_morris's avatar
jane_morris
Occasional Contributor
7 years ago

Type Error - Cannot read perperty 'Click' of undefined

We have a script that is attempting to right click on an icon and then trying to select an item from a menu list.  The error that occurs is

 

JavaScript runtime error. 

TypeError

Cannot read property 'Click' of undefined

 

It is a Delphi application that we are testing.

 

The script is simple

 

function Test1()
{
  var TWAPanel;
  TWAPanel = Aliases.MOP1998.frmMain.pnlMeterID.ClickR();
  TWAPanel.TWAPanelImage.ClickR(39, 40);
  TWAPanel.PopupMenu.Click("History");
}

 

It seems to be not recognising the Click from the PoipMenu.

 

We are using TestComplete v12.30.

 

Does anyone have any suggestions?

 

Thanks

Jane

 

 

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Looking at your code, I see this:

    TWAPanel = Aliases.MOP1998.frmMain.pnlMeterID.ClickR();

    This, I think, is the root of your problem.  ClickR is an action that does not return any result (see https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/onscreen/clickr-action-onscreen-object.html).  So, assigning TWAPanel to the result of ClickR will basically, assign nothing to TWAPanel.  This is where I would start.  I'm actually surprised you're not getting some sort of error trying to call

     

    TWAPanel.TWAPanelImage.ClickR(39, 40);

     

    • jane_morris's avatar
      jane_morris
      Occasional Contributor

      Thanks for having a look, unfortunately this didn't work either.  The scripts I have that worked in version 12.10 

       

      function Adjust_Appointments_Open()

      {

        var mop1998;

        var TWAPanel;

       

        mop1998 = Aliases.MOP1998;

       

        TWAPanel = Aliases.MOP1998.frmMain.pnlMeterID;

        TWAPanel.TWAPanelImage.ClickR();

        TWAPanel.PopupMenu.Click("Actions|Adjust Appointments");

        aqObject.CheckProperty(Aliases.MOP1998.frmAdjustAppts, "Caption", cmpEqual, "System - Adjust Appointments");

        Aliases.MOP1998.frmAdjustAppts.Focused;

      }

       

      This fails in version 12.30.  I have raised this issue with support as I think the issue is where TC is unable to get to the popupmenu which is stated in the Logfile.

       

  • shankar_r's avatar
    shankar_r
    Community Hero

    Hi,

     

    I'm guessing your error comes at TWAPanel.PopupMenu.Click("History");

     

    try the below code and share us the result you got.

     

     

    function Test1()
    {
      var TWAPanel;
      TWAPanel = Aliases.MOP1998.frmMain.pnlMeterID.ClickR();
      TWAPanel.TWAPanelImage.ClickR(39, 40);
      if(TWAPanel.PopupMenu != null)
      {
          TWAPanel.PopupMenu.Click("History");
      }
     else
     {
            Log.Error("Popup menu not found");
     }
    }

    And also, where it is taking when you double clicking the log fail entry