locked
Unable to select 'Context Menu' item RRS feed

  • Question

  • Hi Folks,

    I am not able to select the context menu item that is listed when user right clicks.

    I tried with coordinates reference, start and stop dragging. It is not working. Can any one please help me out in this.

     

    The context menu item is declared in the method. So, in my opinion I should able to achieve this.

    My code looks like,

     

     public void EncoderEmulation_ModeDefault()
            {
                #region Variable Declarations
                WinTreeItem uIEncoderEmulationX9CfTreeItem = this.UIKollmorgenWorkBenchWindow.UINavigationTreeViewWindow.UIStartPageTreeItem.UIAKDTestOnlineTreeItem.UISettingsTreeItem.UIEncoderEmulationX9CfTreeItem;
                WinComboBox uIEmulationModeComboBox = this.UIKollmorgenWorkBenchWindow.UISourceParamComboxWindow.UIEmulationModeComboBox;
                WinMenuItem uISetDefaultMenuItem = this.UIItemWindow.UIDropDownMenu.UISetDefaultMenuItem;
                #endregion

                // Click 'Start Page' -> 'AKDTest (Online)*' -> 'Settings' -> 'Encoder Emulation (X9 Cfg)' tree item
                Mouse.Click(uIEncoderEmulationX9CfTreeItem);

                // Select '1 - Output - A/B with once per rev index' in 'Emulation Mode:' combo box
                uIEmulationModeComboBox.SelectedItem = this.EncoderEmulation_ModeDefaultParams.UIEmulationModeComboBoxSelectedItem;

                // Right-Click 'Emulation Mode:' combo box
                Mouse.Click(uIEmulationModeComboBox, MouseButtons.Right);

                // Click 'Set Default' menu item
                Mouse.Click(uISetDefaultMenuItem);
            }

     

    Thanks,

    Ganesh Kiran

    Thursday, November 3, 2011 3:47 AM

Answers

All replies

  • What is the error here? Do you see context menu appearing after the right click action when the test is running?

     

    -Deepak.

    Thursday, November 3, 2011 5:09 AM
  • Hi

     

    Maybe you could try use the Mouse.Hover method where you do the

    // Click 'Set Default' menu item
    Mouse.Click(uISetDefaultMenuItem);

     

    How to: Record Mouse Hovers in Coded UI Tests

    http://msdn.microsoft.com/en-us/library/hh456251.aspx

     

    so the end result would be something like

    Mouse.Click(Mouse.Hover(uISetDefaultMenuItem, new Point(87, 9));

    I have not tried this, so let me know :-)

     

     

     

    Friday, November 4, 2011 2:09 AM