none
CodedUI Keyboard.SendKeys() not working with Special character RRS feed

  • Question

  • I am inserting value to a Windows security Form. However while using Keyboard.SendKeys() with some special character it opens Server Explorer. Piece of code i am running.

    WinWindow securityWindow = new WinWindow();
    securityWindow.SearchProperties[WinWindow.PropertyNames.Name] = "Windows Security";           
    
    WinEdit username = new WinEdit(securityWindow);
    username.SearchProperties[WinEdit.PropertyNames.Name] = "User name";
    
    WinEdit password = new WinEdit(securityWindow);
    password.SearchProperties[WinEdit.PropertyNames.Name] = "Password";
    
    Keyboard.SendKeys(username,"Admin");
    Mouse.Click(password); 
    
    Keyboard.SendKeys("Winter#123");

    I am working on a Windows Server machine and When script tries to Enter Winter#123 to textbox, it enters upto Winter#1 and then opens Server Explorer. Hence Login got failed.
    Any Ideas ?
    Thanks in Advance.

    Thursday, September 28, 2017 11:01 AM

All replies

  • Hi friend,

    Welcome to this forum.

    >>I am working on a Windows Server machine and When script tries to Enter Winter#123 to textbox, it enters upto Winter#1 and then opens Server Explorer. Hence Login got failed.

    From you code, I could see the before the code Keyboard.SendKeys(username,"Admin");

    there is no any operation or action that could make the WinEdit usename display on the screen, or it's already showed up there?  To implement coded ui, we have to make sure the UI control is displayed.

     

    Best regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Friday, September 29, 2017 3:05 AM
    Friday, September 29, 2017 3:05 AM
  • Thanks for the reply Fletch.

    Yes, WinEdit is already shown up. CodedUI enters username and and also enters password up to Winter#1 and it opens server Explorer. It do not enter the full password. Because of this script fails.

    Friday, September 29, 2017 5:41 AM
  • I see.

    I saw you used its name to search the control, then would mind use AutomationId instead? which is the unique property of each control?

    WinEdit username = new WinEdit(securityWindow);
    username.SearchProperties[WinEdit.PropertyNames.Name] = "User name";

    and the server explorer might also has the same PropertyName?  So you may use more properties of this security window, not only the name, which might also help to distinguish and find the right control.

     

    Best regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Friday, September 29, 2017 6:11 AM
    Friday, September 29, 2017 6:11 AM
  • It uniquely defines both the objects, Insert value to username and password also. However while inserting value to Password field, it enter until fine #1 when this entered it opens Server explorer.
    Friday, September 29, 2017 6:42 AM
  • Hi leon77banga,

    The "#" character means Windows key, which you could check the Remarks in below link.

    https://msdn.microsoft.com/en-us/library/dd419606.aspx?f=255&MSPPError=-2147217396

    So if you want to enter "#" as a common character, please add the "#" in "{}", which is similar with below code.

    Keyboard.SendKeys("Winter{#}123");

    Best Regards,
    Weiwei


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Fletch Zhou Friday, October 6, 2017 8:44 AM
    Monday, October 2, 2017 8:08 AM
    Moderator