Forum Discussion

sdruker's avatar
sdruker
Contributor
10 years ago
Solved

Passing keywordtest name as input parameter to the script

Hi,

I'm trying to write a generic script which gets a keywordtest name and call this:



KeywordTests.Test_Name.Variables.Variable_Name



I read the article:

working with keyword test variables in scripts section in the article below:

http://support.smartbear.com/viewarticle/56810/




I want to get the "Test_Name" as input to the script and run the code but it doesnt work.

It works only if I write the test name and not passing it by parameter



for example:



Function OutputVars(keywordtest_name)



set test=keywordtests.keywordtest_name.Variables

count=test.VariablesCount-1



End Function





Is it possible?



Thanks,

sivan
  • Hi Sivan,

    Use Eval:

     

    Set test = Eval("KeywordTests." + keywordtest_name + ".Variables")  

     

6 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Sivan,

    Use Eval:

     

    Set test = Eval("KeywordTests." + keywordtest_name + ".Variables")  

     

    • VirtualWorld's avatar
      VirtualWorld
      New Contributor

      Hi,

       

      I'm trying to do the same thing in JScript but I can't seem to find a solution.

      Can you please help me?

       

      Kind regards,

      Thomas

       

      P.s. Sorry for bumping an old post.

      • joseph_michaud's avatar
        joseph_michaud
        Moderator

        Does the JScript eval method not work for you?

         

        function mytest()
        {
          var name = "Test2";
          eval("KeywordTests." + name + ".Run();");
        }