? QA Design Gurus: Telerik Test Studio Tip: Less-Expensive alternatives for simulate real Type and simulate real click

Aug 13, 2015

Telerik Test Studio Tip: Less-Expensive alternatives for simulate real Type and simulate real click

In test cases, we often encounter situations which do not work as expected such as normal click 
(Pages.MyDashboardDataDirect.LogOutLink.Click();) or setting value to text box 
(Pages.LoginPage.UserNameTextBox.Text = “User123”;).

For example, take a simple login scenario. Assume we have a login page wherein Submit will be enabled only after user enter User Name through keyboard because developers might be validating and enabling Submit button based on the keyup event. In such case, setting the value to User Name Text Box will not enable Submit button. To handle such type of keyboard or mouse actions, Telerik Test Studio provides an option to simulate these actions with real actions ( SimulateRealTyping, SimulateRealClick). 

The main concern here is, such simulated action demands active session to run. It is expensive for an organization to provide physical machines for running test case on a daily basis or in 24 X 7 mode. Best practice is to avoid such actions and search for an alternative. One way of avoiding such actions is, using JavaScript to trigger actions like keyup,  keydown, click etc. Telerik Test Studio provides a method to invoke JavaScript. An example is given below to explain how to use this method.

Problem definition1

1.Submit button in login page will be enabled based on validation on User Name Text Box.
2. Validation will be called based on key board event( keyup). 

 Solution1 (Not recommended):

Use SimulateRealTyping feature to enter text in the textbox.
Here, test step demands active session to run.

Solution 2 (Recommended):

SetValue to textbox and trigger keyup event using InvokeScript function.

Pages.LoginPage.UserNameTextBox.Text = “User123”;
String JS ="$('[id=name]').trigger('keyup')";
ActiveBrowser.Actions.InvokeScript(JS);


Here, test step will run without an active session.

No comments:

Post a Comment