Coded step methods with parameter

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

    Posted 11 Apr 2012 Link to this post

    How could I return some parameter from 1 method and use it as input parameter in another method?

    I have 2 methods and need to communicate between them
        [CodedStep("Copy and convert Contact URL")]
        public string Copy_ContactURL()
        {
          // Copy URL of current Contact
          string contactURL = ActiveBrowser.Url.ToString();
     
          // Convert URL     
          var nameValueCollection = HttpUtility.ParseQueryString(contactURL);
     
          string[] paramArray = { "preloadcache", "pagemode", "rof", "extraqs" };
     
          for (int i = 0; i < paramArray.Length; i++)
          {
            nameValueCollection.Remove(paramArray[i]);
          }
          contactURL = HttpUtility.UrlDecode(nameValueCollection.ToString());
     
          return contactURL;
        }
     
    ......
        [CodedStep("Open Contact")]
        public void OpenContact(string contactURL)
        {
          ActiveBrowser.NavigateTo(contactURL);
        }
  2. Stoich
    Admin
    Stoich avatar
    1 posts

    Posted 11 Apr 2012 Link to this post

    Hi Alexander,
    coded steps can't be used as a regular function that accepts a parameter and has a return value. Instead, I would suggest to:
    A) Create a Utility class:
    http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/code-samples/general/utility-in-standalone.aspx

    B) Create a static variable inside of the code-behind file (the class that contains your coded steps). Then have the functions write/read this static variable.

    Regards,
    Stoich
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top