Visual Studio Test Agent setup for keyboard input RRS feed

  • Question

  • I'm trying to get my Coded UI test to input a date string in to a textbox that has some jquery validation. The field is a date field that will accept input in the following formats

    numbers (08081988)

    numbers and slashes (08/08/1988)

    numbers and dashes (08-08-1988)

    numbers and decimal (08.08.1988)

    Anything else will cause the jquery to ignore the input.

    When I run the test on my desktop through Visual Studio the date string will input in to the textbox just fine. I can enter data over remote desktop to our automation machine just fine as well. However when I run the automated tests using the Test Agent the jquery fails and nothing gets put in the text field.

    In talking with the developer the jquery is look for "Key Codes". I think the Test Agent may be sending ScanCodes or Ascii to the text field (Maybe somethings else? Anybody know?). This causes the jquery to fail validation and therefore the textbox remains empty.

    I have tried to change my automation code to used <textbox>.text = <string>, Keyboard.SendKeys, My.Computer.Keyboard.SendKeys Windows.Forms.Sendkeys.send andWindows.Forms.Sendkeys.sendwait, break the string up and enter each character one at a time. All have failed to enter data in to the text box while executing the automated test using the Test Agent. I can see where the "SendKeys" is working. The cursor blinks evertime the automation "types" something in the text box but the textbox remains empty.

    Is there a way to change the type of codes that the Test Agent is sending? Is it set on the machine somewhere? Test Controller? Am I doing something else wrong with my coding?

    Any help would be greatly appreciated.

    Wednesday, December 5, 2012 4:48 PM

All replies

  • I'm having the same problem here.  Does any one from MSFT have a suggestion?  How is coded ui sending the keyboard commands to the browser?

    This is definitely blocking our testing efforts from going forward. 

    -Ivan R. Perez

    Wednesday, December 5, 2012 5:17 PM
  • Is anyone able to help me out? My testing is blocked due to this issue.
    Thursday, December 6, 2012 4:52 PM
  • I had a similar problem but I'm not sure it is related.  I had a text field that the automation appeared to locate but it wouldn't input any text.  The day prior I was doing some testing with Chrome and I had forgot to reset the browser type in the .testsettings file.  After selecting the proper browser I was back in business.  I hope your problem is this simple but I suspect it isn't.

    Thursday, December 6, 2012 5:45 PM
  • Thanks for the information. I have checked all Test Setting in Visual Studio and Test Manager and they are all set to a version if IE. We use IE8 and IE9 so it looks like this is not the issue.

    Once again thanks for the idea.

    Thursday, December 6, 2012 7:11 PM
  • I agree, this must not be the browser setting in the .testsettings file.  I'm also intermittently seeing this problem.  The control is found (UIMap.Control.DrawHighlight(); works) but something appears to hang up when trying to set text on the control.  The UI reacts as if it trying and retrying to set the text by brining the window of interest into focus but doesn't appear to time-out (or at least I didn't wait more than a couple of minutes for it to throw some kind of error).  The only work around I've found is to reboot my computer.  There must be a better way.

    Add UIMap.Control.SetProperty("Text", "write something"); to the list of things tried that doesn't work whenever VS gets into this state.

    Thursday, December 6, 2012 9:52 PM
  • Hi,

    Pls. refer the link :


    it may be useful

    Himanshu Mehta

    • Proposed as answer by Himanshu_Mehta Friday, December 7, 2012 6:29 AM
    Friday, December 7, 2012 6:28 AM
  • @ AdamMDavis,

    I am trying to involve someone familiar with this topic to further look at this issue.


    I think you'd reopen one new case about your issue so that you can get better support.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 7, 2012 6:41 AM
  • @RMAuch

    Just want to state here that we have rebooted the environment in the past and this did not fix the issue. My issue is truly related to the jquery and the codes the Test Agent is sending the text box. My coded UI tests work for other textboxes in the system under test
    • Edited by AdamMDavis Friday, December 7, 2012 8:50 PM
    Friday, December 7, 2012 2:40 PM
  • @hcmehta

    Thank you for the link. This is a great intro in to the CodedUI process (And I will keep it for training purposes) but doesn't really answer my issue.

    • Edited by AdamMDavis Friday, December 7, 2012 8:50 PM
    Friday, December 7, 2012 2:41 PM
  • @Vicky Song

    Any update on this?

    Monday, December 10, 2012 2:08 PM
  • “From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs:  http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.”

    Monday, December 10, 2012 9:50 PM
  • I actually figured out what was going on here with help of our developement team.

    One of the developers put the textbox and JavaCode validation in a seperate page and I did a quick CodedUI recording in Visual Studio 2010. During the play back he captured the Key Codes that were coming across.

    Every key press was sending KeyCode 231. This would cause the Validation to fail because it's looking for numbers, /,.,- 

    I then loaded the CodedUI test in to Visual Studio 2012 and ran the test again. This time the Key Codes were coming across as expected.

    So it looks like Visual Studio 2010 and the attached agents are doing something special with Key Code 231. With Visual Studio 2012 this is fixed. I'im guessing that the 2012 Test Agent will have the fix as well.

    Hope this helps someone else out.

    • Proposed as answer by RMAuch Wednesday, March 27, 2013 11:07 PM
    Thursday, December 13, 2012 8:24 PM