Forum Discussion

jaxjeanne64's avatar
jaxjeanne64
Occasional Contributor
13 years ago

Recognizing object properties of Right Click PopUp menus

I am testing a software that uses many Popup menus for many various action/ functions. TC will recognize that there is a popup menu when the R-click occurs and will usually allow it to choose the correct item. The main issue here is that when there is a sub-menu from that first pop-up menu TC is not recognizing the sub-menu. I cannot find any object properties or methods that will recognize that menu. Is there a way to get TC to see that sub-menu?? Is also an issue when validating that an item is available in that menu. 

5 Replies

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Jacqueline,


    To reproduce the problem, I created Delphi and C# applications that use submenus in popup menus. On my computer everything works fine, so at the moment it's difficult to understand what goes wrong in your case. In order for us to answer your questions, please provide us with additional information:


    * What do you mean by saying that TestComplete does not recognize submenu popup menus? You cannot see these objects in the Object Browser, you are not able to record tests on submenus, or TestComplete fails to play back recorded tests?


    * Nearly every software vendor provides their own popup menu type. What application are you testing? (C#, Delphi, VB, Java or some other?) What controls does the application use to implement popup menus? (Microsoft, Developer Express, Infragistics, maybe some other). If you don't know that, please ask your developers.

  • jaxjeanne64's avatar
    jaxjeanne64
    Occasional Contributor
    Alex,

    Thank you for your reply... so the issue is that when using TC i Rclick to get a pop-up menu. Then from that menu I select an item that leads to a submenu off of the popup menu. Now after recording I play back the test script. The first pop-up menu is shown and active and the item is selected that leads to the sub-menu. This is where the issue arises. TC does not see the item to select from the submenu or the list itself. Then it stops running.

    It is a C++ application written in Microsoft Visual Studio using MFC objects.  CMenu is the class that is used to create a popup menu,
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Jacqueline,


    I created a sample C++ application. It has a context menu of the CMenu type and submenus. Again, everything works fine.


    Perhaps, your application creates or uses the context menu in some specific way. Unfortunately, it's difficult to say anything without seeing your test script, test project and application. A menu can be owner-drawn (that is, the menu is drawn by the application code rather than by the operating system). In this case, you can address menu items by indexes:



    ' Addressing an item by index

    Call window.PopupMenu.ClickItem("item_title|[1]")



    See Working With Owner-Drawn and Bitmap Menus and Addressing Menu Items.


    If this does not help, I suggest that you send a request to the SmartBear Support Team. They should be able to help. Please include the following:

    - A description of the issue. You can also include a link to this forum thread.

    - The test project that contains your recorded script.

    - Your application under test (or a sample application that uses the same context menus).

  • jaxjeanne64's avatar
    jaxjeanne64
    Occasional Contributor
    Alex,

    I tried implementing the code you provided but it failed to work... The issue is that the cascading menu gets created at run time, and there is no real ID associated with the Actions "parent" menu item.

    I have included an example of how the cascading menu is created.



    ** This is After a user has selected the item "Actions" from the parent menu. From there the cascading menu is created like so:




    (MF_STRING, ID__SAMPDELSAMPLE, "Delete Samples");

     

    //here is where the dynamic Actions menu comes in

    //I've simplified this a bit from our actual code, but it does practically the same thing

     

    //the menu is built (this is dynamic in our code, it loads the actions from the DB)

    l_actionsmenu.CreatePopupMenu();

    l_actionsmenu.AppendMenu(MF_STRING | MF_ENABLED, ACTIONS_MENU_OFFSET + 1, 'Create Sample');

    l_actionsmenu.AppendMenu(MF_STRING | MF_ENABLED, ACTIONS_MENU_OFFSET + 2, 'Create Aliquot');

     

    //then the cascading menu gets added as the Actions menu item

    pPopup.AppendMenu(MF_STRING | MF_POPUP, (UINT)l_actionsmenu.m_hMenu, "Actions");

     

    //then this command shows the menu

    li_return = pPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, mouse_point.x, mouse_point.y, this);

     

    //then li_return is evaluated and the Scan Mode dialog is shown when it determines what action was run















     

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Jacqueline,


    I tried implementing the code you provided but it failed to work...


    What error did you get?


    As far as I know, the way TestComplete works with context menus does not depend on the way the context menu is created (at run time or at design time), because TestComplete simulates menu item selection after the menu is shown on screen. To check this, I added your C++ code to my application - everything worked fine.


    You wrote about ID and that's not clear to me --


    there is no real ID associated with the Actions "parent" menu item


    What do you mean? Did you use IDs to address menu items? If you did, this is not what I meant. I wrote about indexes; the index is the position (zero-based) of the desired item in the menu...