Forum Discussion

mmcdonald's avatar
mmcdonald
Occasional Contributor
15 years ago

unreliable popup menus

Hi there,

I am using testcomplete 7.52 and have a problem addressing popup menus.  I am trying to open a right click menu on a table cell and then select "options->format cells" to open a dialog box.  I have tried using mouse clicks eg:



   Call tableedit.ClickR(23, 25)

   Call Designer.pm_context.menu_item3.Click    'click "options"

   Call Designer.pm_options.menu_item2.Click       'click "format cells"





I have noticed for different instances of the test, the menu is sometimes recognised differently to testcomplete despite the menu being identical each time (called from the same test, same number of items, same names) and so testcomplete is unable to select "options".  In my NameMapping for the project I have three items:

-NameMapping.Sys.Designer.pm_context.menu_item3

-NameMapping.Sys.Designer.pm_context.menu_item4

-NameMapping.Sys.Designer.pm_context.menu_item5

where the objects are identical except for the ControlIndex property and it seems almost random when each will work as the "options" item during test execution.



I have also tried doing it with key presses and selecting the 22nd option in the menu, then the third option (options is always 22nd and format cells is 3rd):



   Call Tableedit.Keys["Apps"]

   Designer.pm_context.Keys("[down][down][down][down][down][down][down][down][down][down][down][down][down][down][down][down][down][down][down][down][down][down][right][down][down][enter]")



however using this method I get an error "the window was destroyed during method execution".



any ideas on what may be happening and what I can do to reliably select this menu option every time?

6 Replies

  • Hi,



    By what properties are your menu items mapped in Name Mapping? You should be able to map them by captions to avoid such problems.
  • mmcdonald's avatar
    mmcdonald
    Occasional Contributor
    Hi Jared,

    The caption property is always blank.  there is a "ControlIndex" property but this is what seems to change randomly at times.
  • Hi,



    There should be a property which returns the items' text. For example, Text or other native property. If you're able to get text of an item in your application, you can do this in TC. Look at properties of your objects in the Object Browser to find the needed property.
  • mmcdonald's avatar
    mmcdonald
    Occasional Contributor
    It seems like nothing returns the item's text.  I have a caption property but that is always blank.  The only other properties are ControlIndex and ControlIndexInGroup, which both seem to change slightly from time to time.
  • Hi,



    Have you tried enabling the advanced view mode in the Object Browser (see the "Basic and Advanced View Modes" help topic)? This will show more properties of the target object.
  • mmcdonald's avatar
    mmcdonald
    Occasional Contributor
    I don't think I have the option for basic/advanced view in testcomplete 7.52?



    I can see a caption property but it is always blank.  There are two properties that work to address the menu item but they both vary sometimes.

    ControlIndex - varies between 26-28

    ControlIndexInGroup - varies between 22-24



    at the moment my workaround is to have a big if statement each time I want to click something from this menu where item 3, 4 and 5 are all the same thing eg:



      If Not (Designer.pm_Context.menu_item3 Is Nothing) Then

        Designer.pm_Context.menu_item3.Click

      ElseIf (Designer.pm_context.menu_item4 Is Nothing) Then

        Designer.pm_Context.menu_item4.Click

      ElseIf (Designer.pm_context.menu_item5 Is Nothing) Then

        Designer.pm_Context.menu_item5.Click

      Else

        Log.Error("'Format cells' from right click menu could not be invoked")

      End If



    but that is a bit clunky and doesn't always work either.