Ask a Question

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

lkiss
Not applicable

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?



Thanks
1 REPLY 1
AlexKaras
Community Hero

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
Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
cancel
Showing results for 
Search instead for 
Did you mean: