Forum Discussion

gopster1283's avatar
gopster1283
Occasional Contributor
10 years ago

Accessing popup menu items in DevExressGrids

Hey guys:





So our applications are very grid centric, primarily using DevExpress type classes. Now in one of our functional flows, the user has to rightclick the cell (which invokes a popup menu) and select a menu item.



As far as I can see from testcomplete literature, you have to use an index to select the popup menu. Is there any way thatI can use the actual string value of the menu item?



so in my code I have :



WindowObj.PopupMenu.Click(menuItem)



- menuItem is a string like"[0]" where "0" denotes the first item.



Instead of "[0]" i want to use the actual menu item value.



WindowObj.PopupMenu.Click("Open")



I tried GUI Spying on the popup window, and that gave me no info. When I did a recording, TestComplete recorded the event with code as WindowObj.PopupMenu.Click("[0]")





Any ideas?

4 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    Looks like the code generated by the recorder produced a string value.

    Does this not work for you when you try to play it back?



    WindowObj.PopupMenu.Click("Open")



    The string value should be exactly what you see on the menu...
  • gopster1283's avatar
    gopster1283
    Occasional Contributor
    Ryan:



    The recorder produced:



    WindowObj.PopupMenu.Click("[0]") and I want to use the actual name value of the item.



    (I edited my previous statement as it might have misled you.)
    • sbkeenan's avatar
      sbkeenan
      Frequent Contributor

      Presumably you have looked at the available methods and cannot find a 'ClickItem' method, which allows you to specify the text?  In which case, the control should have wItem and wItemCount properties, which should allow you to loop through the items and search for the text you are looking for.  Once you find a match, obtain the item's index and select it based on that.  Somehing along these lines:

       

      [code=JScript]

      var myControl = <a reference to your control>;

      var myOption = "<menu option text here>";

      var found = false;

      for (var i = 0; i < myControl.wItemCount; i++) //locate the item's index number

      {

         if (myControl.wItem(i).toLowerCase() == myOption.toLowerCase()) //index found.

           {

            myControl.SetSelectedIndex(i);

            found = true;

            break;

            }

      }

      if (! found)

      {

          Log.warning("Your selected item '" + myOption + "' does not exist.");

      }

      [/code]

       

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    I see. Well if manually typing in the text WindowObj.PopupMenu.Click("menuitemText") does not work you could use text recognition to click the text object. May be easier just to use the 0 based index unless you are looking to validate the text on the menu.