Transfer variable to Test as a Step

2 posts, 0 answers
  1. algot
    algot avatar
    57 posts
    Member since:
    Nov 2011

    Posted 03 Apr 2012 Link to this post

    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.
  2. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 06 Apr 2012 Link to this post

    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
Back to Top