This is a migrated thread and some comments may be shown as answers.

Unable to perform field level validation

7 Answers 57 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vishal
Top achievements
Rank 1
Vishal asked on 23 Feb 2014, 04:02 PM
Hi,

I am unable to perform field level validation , since whenever I use SetValue(string property, string input) method, it enters all the values in the input text box. 
For example:

I have a input text box that is restricted to two digit numeric values but when i use the SetValue(string property, string input) method  and pass a 3 digit number, it allows to enter 3 digit number. I cross verified manually, the input text box takes only 2 digit value but through the testing framework it enters 3 digit number.

Please let me know how to fix this?

7 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 26 Feb 2014, 06:11 PM
Hi,

Thank you for contacting Telerik support.

Please instead of SetValue try to set focus on the input, perform a click on it and type the digits as a desktop commands. This will simulate a real typing.

yourElement.Focus();
yourElement.MouseClick();
Manager.Desktop.KeyBoard.TypeText("19", 50, 100);

Let me know whether that helps.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Vishal
Top achievements
Rank 1
answered on 27 Feb 2014, 10:21 AM
Hi
Thanks for the reply.

I will check and let you know
0
Boyan Boev
Telerik team
answered on 27 Feb 2014, 11:19 AM
Hello Vishal,

Thank you!

Hope to hear from you soon.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Vishal
Top achievements
Rank 1
answered on 27 Feb 2014, 02:30 PM
Hi 

The below code is able to perform the required operation  but the only problem I am having is how should I clear the default value.

yourElement.Focus();
yourElement.MouseClick();
Manager.Desktop.KeyBoard.TypeText("19", 50, 100);

For example : The input text field is restricted to 2 digits and by default the field has value as 0. Now I want to remove the default value and then enter the new value 45. With the above code if I try to enter 45, it will take the value as 05. Please let me know how to fix this








0
Boyan Boev
Telerik team
answered on 04 Mar 2014, 11:11 AM
Hi Vishal,

You can use either an additional row of code which will press 2 times backspace:

yourElement.Focus();
yourElement.MouseClick();
Manager.Desktop.KeyBoard.KeyPress(Keys.Back, 100, 2);
Manager.Desktop.KeyBoard.TypeText("19", 50, 100);

or you can try it with set value to "".

Note that you should add assembly reference to System.Windows.Forms for the first case.

Hope this helps.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Vishal
Top achievements
Rank 1
answered on 04 Mar 2014, 12:58 PM
Hi Boyan,

Thanks for the reply. I went with the second approach. It worked
Thanks a lot
0
Boyan Boev
Telerik team
answered on 04 Mar 2014, 02:54 PM
Hi Vishal,

Glad to hear that!

Let us know if you need further assistance.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Vishal
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Vishal
Top achievements
Rank 1
Share this question
or