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

Transfer variable to Test as a Step

1 Answer 148 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
algot
Top achievements
Rank 1
algot asked on 03 Apr 2012, 09:09 AM
I want to extract some coded steps from my test to use it by different tests. These coded steps work with variables defined in test and these variables are different in different test.
// define variable
public static string accountEmailDomain = DateTime.Now.ToString("yyMMddHHmmss") + ".com";
 
 
// use it in code
[CodedStep("Enter text in 'Account_EmailDomain'")]
public void Fill_AccountEmailDomain1()
{
  Pages.AccountWindow.FrameContentIFrame.Account_Emaildomain.MouseClick();
  Manager.Desktop.KeyBoard.TypeText(accountEmailDomain, 50, 100);
}
I want to extract CodedStep to separate test, but how I could pass variable 'accountEmailDomain' from current running test?
I only guess to do it like
// use it in separate test
[CodedStep("Enter text in 'Account_EmailDomain'")]
public void Fill_AccountEmailDomain1()
{
  Pages.AccountWindow.FrameContentIFrame.Account_Emaildomain.MouseClick();
  Manager.Desktop.KeyBoard.TypeText(Test1.accountEmailDomain, 50, 100);
}
but I need to pass testname to this separate test.

Please suggest.

1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 06 Apr 2012, 08:29 AM
Hi Alexander,
you can store this variable within a static variable in a Utility class. Here's how to create a Utility class (also includes a static variable of type INT)
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/utility-in-standalone.aspx

Just follow the same approach.

Regards,
Stoich
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
algot
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or