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

Coded step methods with parameter

1 Answer 292 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
algot
Top achievements
Rank 1
algot asked on 11 Apr 2012, 11:21 AM
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);
    }

1 Answer, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 11 Apr 2012, 03:07 PM
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
Tags
General Discussions
Asked by
algot
Top achievements
Rank 1
Answers by
Stoich
Telerik team
Share this question
or