locked
CUIT VS 2010/12/13 is not recording sendkeys actions on MenuBar controltype RRS feed

  • Question

  • Hi Everyone,

    Whenever I try to record send-keys action  on Notepad menu-bar CUIT is not recording actions on Menu-bar it is recording on edit control.

    If I manually modify script to play send-keys action on menu-bar controltype. whenever I playback script CUIT is throwing exception

    Regards,

    Rajendar.

    Thursday, September 11, 2014 1:27 PM

Answers

  • Hi Rajendra,

    Visual Studio Coded UI test plays back what it records. On notepad, the shortcut keys are performed on the text box, so the same action happens in recorded coded UI test.

    I don't have an experience with QTP test case. I believe that the menu bar does not support performing sendkeys on it in coded UI test.

    In coded UI test, you can verify whether the expected objects appear after you press shortcut keys to determine whether the shortcut keys are working fine.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Monday, September 15, 2014 1:47 AM
    • Marked as answer by Amanda Zhu Wednesday, September 17, 2014 9:13 AM
    Friday, September 12, 2014 6:37 AM

All replies

  • Hi Rajendar,

    I expect that it fails because the playback is expecting to be able to implicitly verify the result of the sendkeys. This is normal behaviour, the playback will verify that what is typed into a field is what is seen in the field after the action. I cannot be sure of this without seeing the error message though - can you provide it?

    This can be switched off, but a simpler solution is to remove the control reference from the sendkeys action altogether. If you look here: http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.keyboard.sendkeys.aspx you can see that many of the overloads do not need a UI Control. So if you ensure that the control has focus and then just use something like the following code, you should be ok:

    Keyboard.SendKeys("A");

    I haven't actually tested this so apologies if it fails.

    Good luck,

    Thursday, September 11, 2014 3:08 PM
  • Hi Dominic Wate,

    You can easily reproduce above problem on Notepad menubar control. 

    Error information:

    -----------------------------------------------------

    Test Name: CodedUITestMethod1
    Test FullName: SampleTestCUIT.CodedUITest1.CodedUITestMethod1
    Test Source: c:\Users\rmanda\Documents\Visual Studio 2013\Projects\SampleTestCUIT\SampleTestCUIT\CodedUITest1.cs : line 27
    Test Outcome: Failed
    Test Duration: 0:00:06.37626

    Result Message:
    Test method SampleTestCUIT.CodedUITest1.CodedUITestMethod1 threw exception: 
    Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException: Cannot perform 'SendKeys with value "^(u)"' on the control. Additional Details: 
    TechnologyName:  'MSAA'
    Name:  'Application'
    ControlType:  'MenuBar'
     ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
    Result StackTrace:
    at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.SendKeys(String bstrKeys, Int32 nKeyboardAction, Int32 nSendKeysFlag)
       at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.SendKeys(String keys, Boolean isUnicode)
       at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.SendKeys(String keys, ModifierKeys modifierKeys, Boolean isEncoded, Boolean isUnicode)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SendKeys(String text, ModifierKeys modifierKeys, Boolean isEncoded, Boolean isUnicode)
     --- End of inner exception stack trace ---
        at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowComException(COMException innerException, IPlaybackContext context)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, IPlaybackContext context)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String actionName, UITestControl uiControl)
       at Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(Exception exception, String actionName, Object parameterValue, UITestControl uiControl)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SendKeys(String text, ModifierKeys modifierKeys, Boolean isEncoded, Boolean isUnicode)
       at Microsoft.VisualStudio.TestTools.UITesting.UITestActionExecutorCore.SendKeys(UITestControl control, String text, ModifierKeys modifierKeys, Boolean isUnicode, Boolean isEncoded)
       at Microsoft.VisualStudio.TestTools.UITesting.Keyboard.SendKeysImplementation(UITestControl control, String text, ModifierKeys modifierKeys, Boolean isEncoded, Boolean isUnicode)
       at Microsoft.VisualStudio.TestTools.UITesting.Keyboard.<>c__DisplayClass2.<SendKeys>b__1()
       at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
       at Microsoft.VisualStudio.TestTools.UITesting.Keyboard.SendKeys(UITestControl control, String text, ModifierKeys modifierKeys, Boolean isEncoded, Boolean isUnicode)
       at Microsoft.VisualStudio.TestTools.UITesting.Keyboard.SendKeys(UITestControl control, String text, ModifierKeys modifierKeys)
       at SampleTestCUIT.UIMap.RecordedMethod1() in c:\Users\rmanda\Documents\Visual Studio 2013\Projects\SampleTestCUIT\SampleTestCUIT\UIMap.Designer.cs:line 48
       at SampleTestCUIT.CodedUITest1.CodedUITestMethod1() in c:\Users\rmanda\Documents\Visual Studio 2013\Projects\SampleTestCUIT\SampleTestCUIT\CodedUITest1.cs:line 29

    ------------------------

    Is it abug in CUIT?

    Regards,

    Rajendar.

    Friday, September 12, 2014 5:00 AM
  • Hi Rajendar,

    Through dragging crosshair on the notepad, I understand that MenuBar control in notepad is the control below:

    Whenever I try to record send-keys action  on Notepad menu-bar CUIT is not recording actions on Menu-bar it is recording on edit control.

    This is a default behavior, moreover we get the same result when we press send keys on the menu bar manually in notepad without recording actions using Coded UI Test Builder.

    The menu bar is not an edit control, so I don’t know why you operate send keys on it. When we press send keys on the menu bar, actually it is made in the text box within notepad because the cursor is in the text box rather than menu bar.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 12, 2014 6:03 AM
  • Hi Crystal Zhu,

    Thanks for quick response.

    Here my test case is to check whether shortcut keys are working fine or not on ' MenuBar ' control. How do I automate this test case using CUIT.

    I can test this Test Case using QTP.

    Regards,

    Rajendar.

    Friday, September 12, 2014 6:20 AM
  • Hi Rajendar,

    better if you write a method use descriptive programming to performing action on menu bar, other wise you need to record all menu bar controls one by one in your in your UIMap file and call that controls in ypur script. sure this will work. if any you can write us.

    I hope this will help you.

    Thanks,

    Friday, September 12, 2014 6:28 AM
  • Hi Krishna,

    Do you mean by default CUIT does not this case? which is supported by QTP

    Regards,

    Rajendar.

    Friday, September 12, 2014 6:37 AM
  • Hi Rajendra,

    Visual Studio Coded UI test plays back what it records. On notepad, the shortcut keys are performed on the text box, so the same action happens in recorded coded UI test.

    I don't have an experience with QTP test case. I believe that the menu bar does not support performing sendkeys on it in coded UI test.

    In coded UI test, you can verify whether the expected objects appear after you press shortcut keys to determine whether the shortcut keys are working fine.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Amanda Zhu Monday, September 15, 2014 1:47 AM
    • Marked as answer by Amanda Zhu Wednesday, September 17, 2014 9:13 AM
    Friday, September 12, 2014 6:37 AM