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

Automated unique registration value

1 Answer 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark Cooper
Top achievements
Rank 1
Mark Cooper asked on 09 Sep 2011, 01:36 PM
I'm testing the registration form for my application. I want to use a unique email address (either an incremental integer or maybe a date string).

Is this possible to do via the QA version without writing code? If, not, what other approaches are there to get this working?

Is it possible to then parameterise this value for use by other test steps?

Thanks,
Mark

1 Answer, 1 is accepted

Sort by
0
Accepted
Stoich
Telerik team
answered on 12 Sep 2011, 01:02 PM
Hi Mark,
    you"ll need a coded step for this but it won't be complex to implement.

First off: in code you can set a so-called Extracted Value:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/knowledge-base/data-driven-testing/extracted-variables-in-code.aspx

Once set, you can access this value without code (i.e. use it as a parameter) in the same way as normal databinding:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/data-driven-testing/attach-columns-to-input-values.aspx

So you just need to write the code that generates a random String in a coded step and then set it as an Extracted Value. From there you can access it without any further coded steps. Generating a random String is very straightforward. I followed the following tutorial:
http://www.c-sharpcorner.com/UploadFile/mahesh/RandomNumber11232005010428AM/RandomNumber.aspx

Here's what my code step looks like:
StringBuilder builder = new StringBuilder();
Random random = new Random();
char ch ;
 
for(int i=0; i<7; i++)
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
builder.Append(ch);
}
this.SetExtractedValue("myRandomString",builder.ToString().ToLower());

You can access this value by using $(myRandomString).

Let me know if you require any additional assistance with this.

Greetings,
Stoich
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Mark Cooper
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or