Forum Discussion

lkiss's avatar
14 years ago

Calling a keyword test using the string representation of the actual test

My goal is to create a vbscript function that has one string parameter.  The string parameter will be the name of a keyword test to run within the vbscript function.  Is there a way to use the KeywordTests object to lookup the corresponding keyword test based on this string?  If not, is there another way to achieve running a keyword test based on the string representation of the test itself?


1 Reply

  • AlexKaras's avatar
    Champion Level 3
    Hi Lawrence,

    Have a look at the native VBScript's Eval() function.

    The code (untested mockup) may be like this

    Function RunKWTest(ByVal strTestName)

      ' will not work if keyword test returns an object

      ' code must be enchanced if parameters support for keyword test is needed

      RunKWTest = Eval("KeywordTests." & strTestName & ".Run")

    End Function