Forum Discussion

Soren's avatar
Soren
Occasional Contributor
9 years ago

Mapping ToolStripDropdownMenu in keyword testing

Hi,

We are doing keyword testing and are just getting started with TestComplete. However, we have run into an issue with the .NET item ToolStripDropDownMenu.

 

We have added it using “Add From Screen” method in the Miscroft Winforms, but that hasn’t solved our issue.

 

The issue is when we map the dropdowns they have the base class, so we have no way of knowing which ToolStripDropDownMenu we are actually hitting when we run the tests and it has resulted in several tests failing because of TestComplete being unable to identify the relevant dropdowns.

 

I have added an example on how the mapping looks like base in a small mocked up application(Attached as well if anyone is interested)

 

Top ToolStripDropDownMenu: Sys.Process("BlandetSlik").WinFormsObject("Form1").WinFormsObject("toolStripContainer1").WinFormsObject("ToolStripPanel", "", 4).WinFormsObject("menuStrip1")

 

Bottom ToolStripDropDownMenu: Sys.Process("BlandetSlik").WinFormsObject("Form1").WinFormsObject("toolStripContainer1").WinFormsObject("ToolStripPanel", "", 5).WinFormsObject("menuStrip2")

 

Try to guess which of the actual dropdownMenues have been mapped:

Sys.Process("BlandetSlik").WinFormsObject("ToolStripDropDownMenu", "")

screenshot.png

And you guessed wrong, the picture just shows one of the 4 dropdownmenu’s in this little application, the one that as mapped was actually the “Bottom”.

 

So the question is – how can we ensure that the right toolstripdropdownmenu is hit in our tests everytime?

 

Kind Regards

Soeren Gormsen

QA Manager

NIS

 

 

  • What you have shown is full name of the object which looks similar except WinFormsObject("ToolStripPanel", "", 4)  the number. And I think that number may be random or created dynamically .

     

    To identify two menus separately you have to use unique property of these objects. eg ("Caption" or unique child object).
    You can play around with object spy on your objects and find unique property to manually map two objects.


    You can read more in this subject here ..using advance mapping setting is relevent to your question


    if nothing helps, ask developers to inclued a unique property in to the object

  • NisHera's avatar
    NisHera
    Valued Contributor

    What you have shown is full name of the object which looks similar except WinFormsObject("ToolStripPanel", "", 4)  the number. And I think that number may be random or created dynamically .

     

    To identify two menus separately you have to use unique property of these objects. eg ("Caption" or unique child object).
    You can play around with object spy on your objects and find unique property to manually map two objects.


    You can read more in this subject here ..using advance mapping setting is relevent to your question


    if nothing helps, ask developers to inclued a unique property in to the object

    • Soren's avatar
      Soren
      Occasional Contributor

      Hi NisHera,

       

      Thank you for your suggestion. I have look at the various properties and discussed them with the developper that is allocated to our test automation project. Sadly we have found none that we feel confident that we can use. But that would definitily have been a solution.

       

      But we have actually figured away around the issue. Most of our ToolStripDropDownMenu's have keyboard shortcuts, so if we use thos in our keyword test to envoke the various menu's we can ensure we hit the right one everytime. Thos that doesn't have will keyboard shortcuts added to them.

       

      Kind Regards

       

      Soren

      • Jimbo's avatar
        Jimbo
        Occasional Contributor

        Hello,

        I've tried demonstrating the problem we see with this little sample application, and it seems I get the same mapping no matter which toolstrip drop-down menu I'm pointing at.

         

        In this video you can see how I "pick" four different menus, and regardless of which menu item I choose, I get the same object path: Aliases.BlandetSlik.WinFormsObject("ToolStripDropDownMenu", "", 1). All four menus are number 1. Even the additional menus at the bottom are also number 1.

         

        I tried enabling "Extended find" on my name mapping and telling it to use .Text (which in .NET contains the text visual on each menu strip item), but this did not help. Adding a unique ".AccessibleName" to each menu and menu item item also did not help either.

         

        What can be done here?

         

        I've also added the example application too (this time with english texts and .AccessibleName set on each and every UI component).