Forum Discussion

surbhik's avatar
surbhik
Occasional Contributor
3 years ago

ClickItem() not working for MainMenuStrip

I am testing a .NET project and have a MainMenuStrip object which further has a ToolstripDropDownMenu. 

This does have a ClickItem() function associated with it.

When I do a record and play, it just clicks on coordinates. I want to give code like ClickItem("Edit|Copy"). The customized class name is 

<clientname>.<app>.UI.MenuController.LHMenuStrip

 

Please let me know what can be done to acheive the desired functionality. 

 

function Test2()
{
let catsv3 = Aliases.CATSV3;
let LHMenuStrip = catsv3.TabWindow.mainMenuStrip;
LHMenuStrip.Click(94, 13);
catsv3.ToolStripDropDownMenu.Click(38, 13);
}

  • HI surbhik.

     

    A couple of things that might cause the ClickItem() failure.

    1. Your path might require the path separator (a pipe in your case) at the very begnining...so

    "Edit|Copy" might need to be "|Edit|Copy"

    2. the drop down menu might use a different path separator than the Pipe, like a backslash, so you need to check that. You should be able to see that property it with the ObjectSpy or you can just get it in the code.

     

    Here would be a modified version of your original code...

     

    function Test2()
    {
      let catsv3 = Aliases.CATSV3;
      let LHMenuStrip = catsv3.TabWindow.mainMenuStrip;
      LHMenuStrip.Click(94, 13);
      // your path might require a pipe to start
      var menuItemPath = "|Edit|Copy";
      // if the menuStrip has a pathSeparator then you might need to get that and replace the pipes in your path
      if (aqObject.IsSupported(catsv3, "PathSeparator") && catsv3.ToolStripDropDownMenu.PathSeparator != "|")
         menuItemPath = aqString.Replace(menuItemPath, "|",  catsv3.ToolStripDropDownMenu.PathSeparator,);


      catsv3.ToolStripDropDownMenu.ClickItem(menuItemPath );
    }

     

    I hope this helps.