Comparing Field Values Using Extract and Coded Step

7 posts, 0 answers
  1. lora
    lora avatar
    8 posts
    Member since:
    Aug 2011

    Posted 02 Jul 2012 Link to this post

    (Silverlight)

    Anyone have experience using EXTRACT to pull a data vlaue into a variable and then writing code to compare that extacted value against data in another field?

    Ex.
    Field A
    Field B

    I need to compare Field B value to what was entered in Field A. If Field B > than Field A, I need to verify that an error message is thrown back on Field A. Silverlight uses a control that outlines the field in red and then presents the error on hover over the upper left corner of the input box.

    Telerik Support suggested using Extract during recording and then writing code to compare the values as intergers in  a coded step. I'm still not able to verify that an error message is thrown if Field B > Field A.



  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 02 Jul 2012 Link to this post

    Hello Iora,

    After adding the Extraction steps and customizing the DataBindVariableNames (below I used fieldA and fieldB), your coded step will resemble the following:

    int a = Convert.ToInt32(GetExtractedValue("fieldA"));
    int b = Convert.ToInt32(GetExtractedValue("fieldB"));
     
    if (b > a)
    {
        //custom code
    }
    else
    {
        //do nothing
    }

    The custom code that goes under the IF branch will be unique to your application. My guess is you could combine the sample that grab's a Silverlight Tool-tip, and then verify the tool-tip's string is not empty.

    Regards,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. lora
    lora avatar
    8 posts
    Member since:
    Aug 2011

    Posted 03 Jul 2012 Link to this post

    I'm attempting to use the Extract feature, but am not getting the same options as shown on the Create An Extraction Step in Telerik's documentation. http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/verifications/data-bind-an-extraction-step.aspx

    In your documentation, the example shows "Extract - text contains 'flow'"

    But, when I use the feature, I am not able to extract the actual field value of '2'.
    I am seeing only the following options:
    Extract - Element visibility is Collapsed
    Extract - left side position is 908
    Extract top side position is 439

    See attached for screenshot.

  4. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 03 Jul 2012 Link to this post

    Hello Iora,

    That article was written against an HTML site, so a Silverlight extraction will be slightly different. For a Generic Silverlight Control, don't click the first blue nub (see screen shot 1), which targets the base element. Instead click one of the next nubs that targets to the TextBox, TextBlock, or whatever element holds the text (see screen shot 2).

    All the best,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  5. lora
    lora avatar
    8 posts
    Member since:
    Aug 2011

    Posted 03 Jul 2012 Link to this post

    This worked great, and I was able to complete the extraction and coded comparison. The issue for the extraction was I had to hover across the input field, and the pointer had to be in a certain position, in order to invoke the second blue nub (radmaskedtextbox).

    Thanks for your help!
  6. Amit
    Amit avatar
    2 posts
    Member since:
    Jan 2013

    Posted 17 Jan 2013 Link to this post

    I need that code for Extract and comparison but in my case the standard values are in different page not in the same page Can someone help me ?

    Thanks,
  7. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 22 Jan 2013 Link to this post

    Hi Amit,

    All you need to do is to create an Extract step against a value seen on the current page. Then navigate to next page and create a Verification step against a value seen there. After that Attach the DataBindVariable to the Verification step and Test Studio will compare these two values for you.

    Let me know if we can assist you further with this.

    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top