This is a migrated thread and some comments may be shown as answers.

How to use class level variables in data driven recorded step

3 Answers 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dipali
Top achievements
Rank 1
Dipali asked on 30 Apr 2012, 03:46 PM

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?

3 Answers, 1 is accepted

Sort by
0
Dipali
Top achievements
Rank 1
answered on 02 May 2012, 02:08 PM

Hey guys,

I am waiting for your reply.

0
Accepted
Plamen
Telerik team
answered on 02 May 2012, 06:24 PM
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
0
Dipali
Top achievements
Rank 1
answered on 03 May 2012, 04:02 PM
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!!!
Tags
General Discussions
Asked by
Dipali
Top achievements
Rank 1
Answers by
Dipali
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or