21 Answers, 1 is accepted

There is some ways this can be made.
Sample code (C#):
var myApplication = ActiveBrowser.Desktop;
var textBox = myApplication.MyTextBox;
MyTextBox.User.KeyPress(Key.Enter, 5);
// Summary:
// Press a key and hold it down for a specific period of time.
//
// Parameters:
// key:
// The key code for the key to press.
//
// holdFor:
// How long to hold the key down, in milliseconds.
public
void
KeyPress(Keys key,
int
holdFor)

Hello.
I don't understand what is 'MyTextBox' in
var textBox = myApplication.MyTextBox;
I need to send keys for HTML Controls.
Jonas's code sample is for a Silverlight application. I'm going to assume you're dealing with an HTML based application. In this realm the framework doesn't really understand the concept of "Press Enter on an element". Instead we need to do two steps:
1) Click on the element to give it input focus
2) Simulate pressing the Enter key on the keyboard
Here's some sample C# code to do this:
HtmlInputText input = ActiveBrowser.Find.ById<HtmlInputText>(
"inputid"
);
Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, input.GetRectangle());
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);
To get the VB equivalent just use our code converter. Greetings,
Cody
the Telerik team
Test Studio Trainings

Thanks, it's works for me:
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter, 100);


oh...
It works for me
.Manager.Desktop.KeyBoard.KeyPress(Keys.Enter, 100, 3);
I am glad to hear you found a solution! Thank you for the update.
All the best,Cody
the Telerik team
Test Studio Trainings

Can u please tell how to get this Manager.Desktop.Keyboard reference?? I can't find any dll file for it nor when i type this code in silverlight project, it gives any sort of reference to it. Actually i need to send F11 key on button click in silverlight... Is there any way to do so?
You can use the Manager.Desktop.Keyboard class only in a test project. The Manager object cannot be used in your Silverlight project. See the bottom of this page for more information on the Manager object.
Maybe you can accomplish your goal using the SendKeys Class.
Regards,
Plamen
the Telerik team
Test Studio Trainings

Is there any other way to send keys in silverlight...??
I am sorry but that is beyond the scope of Test Studio support. This forum is dedicated to supporting our Telerik Testing Framework product. That's really a question for the Microsoft Silverlight team since you're dealing with a Silverlight app and thus unrelated to Telerik Testing Framework.
Regards,
Plamen
the Telerik team
Test Studio Trainings

I have tried exactly the code you described to Anton with regard to the HTML application as I have the same need. I am able to set the input on the correct field via the mouse click, however the Keypress does not appear to do anything. When I try to run my test in debug mode, no error is thrown by the Keypress line.. Nothing seems to happen at all.
Any assistance on this would be greatly appreciated.
I am sorry you are running into this problem.
What code exactly do you use? What do you want to type in the field?
Please double check that the focus is on the particular input.
You can also use this code:
Manager.Desktop.KeyBoard.SendString("asdfasdf");
Let me know if this helps.
Regards,
Boyan Boev
Telerik
Test Studio Trainings

<
Test
, TestCase(Titan.AdminUser, Titan.AdminPW, Titan.AdminUserDesc)>
Public Sub LoginSuccessViaEnter(userName As String, password As String, fullName As String)
' Navigate directly to the login page
Titan.TitanManager.ActiveBrowser.NavigateTo(Pages.ClientLogin.Path)
Titan.TitanManager.ActiveBrowser.WaitUntilReady()
Dim userNameField As HtmlInputText = Titan.TitanManager.ActiveBrowser.Find.ByName(Of HtmlInputText)("ctl00$ContentPlaceHolder1$txtUserId")
Dim passWordField As HtmlInputPassword = Titan.TitanManager.ActiveBrowser.Find.ByName(Of HtmlInputPassword)("ctl00$ContentPlaceHolder1$txtPassword")
userNameField.Text = userName
passWordField.Text = password
' TODO: FIX THIS TO TRIGGER AN ENTER KEYPRESS
Titan.TitanManager.Desktop.Mouse.Click(MouseClickType.LeftClick, userNameField.GetRectangle())
Titan.TitanManager.ActiveBrowser.Manager.Desktop.KeyBoard.KeyPress(Windows.Forms.Keys.Enter)
Titan.TitanManager.ActiveBrowser.WaitUntilReady()
Titan.CheckCurrentUrl(Pages.Home.Path)
Dim loginHeaderText As String = Titan.TitanManager.ActiveBrowser.Find.ById(Of HtmlAnchor)("ctl00_hypAUser").InnerText
StringAssert.AreEqualIgnoringCase(loginHeaderText, fullName)
End Sub
I have also tried this instead of the Keypress method and it also appears to do nothing.
Titan.TitanManager.Desktop.KeyBoard.SendString("test")

Titan.TitanManager.ActiveBrowser.Desktop.KeyBoard.KeyPress(ArtOfTest.WebAii.Win32.KeyBoard.KeysFromString("Enter"), 150, 1)
However, I have a new issue. After the enter keypress, the ActiveBrowser.Url does not appear to change (the login triggers a redirect - in the version of this test where I login in via a button click instead of pressing enter, ActiveBrowser.Url does change as expected).
At first I thought that the code was simply moving on too quickly so I tried WaitUntilReady() to no success. Eventually I tried simply sleeping the thread for a few seconds as sort of a brute-force solution but even after sleeping it and where I could see the correct page was loaded in the browser, ActiveBrowser.Url had not changed.
Any ideas?

This is very strange issue that we have never seen.
What is happening if you refresh the page (i.e. ActiveBrowser.Refresh();)?
Another thing you can try is to replace sending key Enter with a click step with SimulateRealClick property set to true (i.e. yourElement.MouseClick(MouseClickType.LeftClick);).
Hope this helps.
Regards,
Boyan Boev
Telerik
Test Studio Trainings

Unfortunately Windows Phone is not supported for automation at this point of product development. In this article and related links you could fine all information related to the mobile automation aspect as a feature set in Test Studio.
Kind Regards,
Nikolay Petrov
Progress Telerik
Test Studio Trainings

Hi Guys,
I was trying to perform some Keyboard operations (Key Press and Tab etc) in sample CRM application provided by Telerik using telerik test studio v 2018.2.
I have recorded the case and when i am compiling the coded file its giving me below error :
D:\Users\patiwari\Documents\Test Studio Projects\PracticeTelerik\WPFTest.tstest.vb(62,0) : error BC30451: 'Keys' is not declared. It may be inaccessible due to its protection level.
D:\Users\patiwari\Documents\Test Studio Projects\PracticeTelerik\WPFTest.tstest.vb(65,0) : error BC30451: 'Key' is not declared. It may be inaccessible due to its protection level.
Also attaching the screenshot of my code file
Can anyone help me into this how i can resolve this issue.
Many Thanks in Advance..
Thank you for your interest in Test Studio.
If you are about to use the Desktop Manager you will need to add reference in the Test Studio project to System.Windows.Forms.dll as described in the first note in this article.
I hope this will be helpful to you. Thank you!
Regards,
Elena Tsvetkova
Progress Telerik
Test Studio Trainings