Parse Extracted Text

2 posts, 1 answers
  1. Austin
    Austin avatar
    4 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2012 Link to this post

    After saving an order in my web application a pop up box comes up with text and the order number.

    I need a way to parse the text so the variable saved from the extraction is only the order number.

    (I have visual studio also so if i need to do it there I can).
  2. Answer
    Anthony avatar
    19 posts

    Posted 18 Jun 2012 Link to this post

    Hello Austin,

    This can be done in a Coded Step. You'll reference the extracted variable in code, convert it to a string, and use the String.Substring Method to trim it. (That method is basic .NET code and not specific to Test Studio.)

    Here's an example:

    object webTime = GetExtractedValue("Time");
    string extractMe = webTime.ToString();
    int n = extractMe.IndexOf("at ") + 3;
    extractMe = extractMe.Substring(n);

    And the resulting log:

    LOG: Monday, June 18, 2012 at 2:57:38 PM
    LOG: 2:57:38 PM

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