cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted
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
Highlighted
Community Hero

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

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
================================
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
A new challenge is here!

Create a function to drag one element to another for the TechCorner tag!

Will you dare to take the challenge?


Scripts created in July:
- Passing custom command-line arguments as a test parameter
Top Kudoed Authors