Search code examples
coded-ui-tests

CodedUI Keyboard.SendKeys() not working with Special character


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.


Solution

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