How to use class level variables in data driven recorded step

4 posts, 1 answers
  1. Dipali
    Dipali avatar
    16 posts
    Member since:
    Mar 2012

    Posted 30 Apr 2012 Link to this post

    Hi Telerik Team,

    for the automated tests I want to generate a unique data for testing. I am creating a record in my application for which the Record Name must be unique so that it would be easy to search. To generate unique record name I am appending DateTime value to the ‘Record Name’ I am reading from input xls via a coded step.

    Though I am able to create a new record having unique name by appending Datetime, while searching I want the exact name which I had entered while creating a record. I have declared record name as a class level variable. So I can access it in all the coded steps. But the search functionality has all recorded steps. How can I use a class level  variable from a coded step, in the data driven recorded step?

  2. Dipali
    Dipali avatar
    16 posts
    Member since:
    Mar 2012

    Posted 02 May 2012 Link to this post

    Hey guys,

    I am waiting for your reply.

  3. Answer
    Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 02 May 2012 Link to this post

    Hello Dipali,

    Unfortunately you cannot bind a recorded step to a string variable. The closest thing is to use the SetExtractedValue method as seen in this article. For example, you can add the following coded step as a very first step:
    public void WebTest1_CodedStep()
    {
        SetExtractedValue("UniqueRecordName", System.DateTime.Now.ToString() + " " + Data["Record Name"].ToString());   
    }

    Then you can bind a recorded step to the 'UniqueRecordName' value. Check this video to see how it works. The sample test attached.
     
    Regards,
    Plamen
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  4. Dipali
    Dipali avatar
    16 posts
    Member since:
    Mar 2012

    Posted 03 May 2012 Link to this post

    Hi Plamen,

    Thanks for solution. This is perfectly working fine for me. Additionally its giving me advantage of accessing the extracted value in other tests as well. I could sucessfully bind the extracted value to the recorded stepp from the same test as well to the recorded step from the other test.
    Thanks a bunch!!!
Back to Top