Unable to perform field level validation

8 posts, 0 answers
  1. Vishal
    Vishal avatar
    18 posts
    Member since:
    Jan 2014

    Posted 23 Feb 2014 Link to this post

    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?
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 26 Feb 2014 Link to this post

    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
  3. Vishal
    Vishal avatar
    18 posts
    Member since:
    Jan 2014

    Posted 27 Feb 2014 in reply to Boyan Boev Link to this post

    Hi
    Thanks for the reply.

    I will check and let you know
  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 27 Feb 2014 Link to this post

    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
  5. Vishal
    Vishal avatar
    18 posts
    Member since:
    Jan 2014

    Posted 27 Feb 2014 in reply to Boyan Boev Link to this post

    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








  6. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 04 Mar 2014 Link to this post

    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
  7. Vishal
    Vishal avatar
    18 posts
    Member since:
    Jan 2014

    Posted 04 Mar 2014 in reply to Boyan Boev Link to this post

    Hi Boyan,

    Thanks for the reply. I went with the second approach. It worked
    Thanks a lot
  8. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 04 Mar 2014 Link to this post

    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
Back to Top