How to do Field Level Validation

2 posts, 0 answers
  1. jay
    jay avatar
    1 posts
    Member since:
    Dec 2014

    Posted 17 Dec 2014 Link to this post

    Hi there,

    My scenario is : To validate each fields in my application with both positive and negative data.Additionally the validation result will be stored on the excel file.

    I have recorded those controls and its working even in play back.

    I have a first name field(a text box)  ,i supposed to give both negative and positive data's from excel file.

    The alert box will be appear, if we entered a negative data.

    I have validated the fields with negative data by using code :

                if (ActiveBrowser.ContainsText("Please Enter Valid FirstName")) // Please enter valid firstname - is a alert box text
                    Worksheet.Cells[Data.IterationIndex + 2, 4] = "Please Enter Valid First Name"; //storing result in excel
                    Worksheet.Cells[Data.IterationIndex + 2, 4] = "error";
    Its working for the negative data's alone,not for the positive data.

    How do i validate fields with positive data? Please Help me on this ...

    I have enclosed a sample screenshots for your reference.

  2. Konstantin Petkov
    Konstantin Petkov avatar
    1911 posts

    Posted 22 Dec 2014 Link to this post


    Your approach seems to be based on the text in the browser, which is probably easier but too limited approach. I'd recommend trying another approach - validation based on elements, which Test Studio is pretty powerful with. One can give the Test Studio recorder a try and record verifications based on the highlighted element or if you prefer coded solution find your elements dynamically. For reference please take a look at the links below and let us know if you need further assistance.

    Getting started with test recording
    Test Studio Verifications
    Recording Quick Verifications

    Konstantin Petkov
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top