Forum Discussion

simonaferrara's avatar
simonaferrara
Frequent Contributor
5 years ago

ContextMenuStrip click action doesn't work

Hi,
 
I've got an issue on my desktop app; the click on a sub-menu belonging to the class ContextMenuStrip doesn't work.
I'll try to give you some information, but ask me if you need other details.
 
The issue is related to a menu that is displayed after doing a right-click on a treeView.
As example, this is the structure :
Parent
|_Child1

  |_Child2

      |_ Child3

         |_ Child4
If the Child4 is right-clicked, a submenu (it belongs to ContextMenuStrip class) appears, with the following structure:
- New
- Delete
- Update
Then, if the New item is clicked (or on mouse over), another menu appears (it belongs to ToolStripDropDownMenu class) and I want, at the end, to click on one element of this menu.

The actual code correctly executes the right-click, but then it stops, with an error when it has to click on the first submenu (on New item for example).
 
I've tried to record it and this is the generated code (VBScript):
 

 

Sub Test1
  Dim EDashBoard
  Dim tabControl
  Set EDashBoard = Aliases.EDashBoard
  Set tabControl = EDashBoard.HwndSource_ribbonwindow.WinFormsAdapter.SystemConfiguratorMainForm.toolStripContainer1.ToolStripContentPanel.splitContainer1.SplitterPanel2.splitContainer2.SplitterPanel.tcMain
  Call tabControl.ClickTab("Parent")
  Call tabControl.tabSystemSettings.SystemExplorerWrapperOne.seDB.trvProject.ClickItemR("|Parent|Child1|Child2|Child3|Child4")
  Call EDashBoard.ContextMenuStrip.Click(40, 19)
  Call EDashBoard.ToolStripDropDownMenu.Click(85, 127)
End Sub
 

 

But later if I execute the recorded test, it doesn't work.
This is the error generated: "The object "ContextMenuStrip" does not exist" and t
he error appears on ContextMenuStrip.Click row.

 

I've tried to click it using both the FullName or the Alias into the code (and not the recorded code), but it doesn't work.

Morever, I cannot find the object by Id because it seems a dynamic object (the Id changes every time the menu is opened).

 

The strange thing is that: if I use the Object Spy with Point and Fix and try to open it into the Object Tree, the following error appear "Unable to highlight this object tree, because it does not exist".

 

Do you have any idea to solve this issue?

 

Thanks!

Simona

  • Try recording a test where you follow those menus and look at how TestComplete is seeing them.  That should give you a clue as to how the name mapping needs to be updated.

  • Try recording a test where you follow those menus and look at how TestComplete is seeing them.  That should give you a clue as to how the name mapping needs to be updated.

    • simonaferrara's avatar
      simonaferrara
      Frequent Contributor

      Hi Marsha,

       

      how can I understand if name mapping must be updated? 

      I found that the ContextMenuStrip exixts into NameMapping, and no other object have the same FullClassName.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Simona,

     

    Can you let us know how ContextMenuStrip and ToolStripDropDownMenu are NameMapped?

     

    • simonaferrara's avatar
      simonaferrara
      Frequent Contributor

      Hi,

       

      the MappedName property values for the two objects are the following:

       

      Aliases.EDashBoard.ContextMenuStrip

      and

      Aliases.EDashBoard.ToolStripDropDownMenu