Forum Discussion

Kateryna's avatar
Kateryna
Contributor
13 years ago

Name of keyword tests

Hello,



Is it possible to get the name of current keyword test and save it to variable?



Thank you in advance.

Kateryna

  • Hi,



    If you run your test via a test item, you can get its name via the test item's ElementToBeRun property. Here's the full name of the property whose value you need to get (for example, via the [url=http://support.smartbear.com/viewarticle/11075/]Call Object Method operation[\url]):

    Project.TestItems.Current.ElementToBeRun.Caption
  • Hi,



    If you run your test via a test item, you can get its name via the test item's ElementToBeRun property. Here's the full name of the property whose value you need to get (for example, via the [url=http://support.smartbear.com/viewarticle/11075/]Call Object Method operation[\url]):

    Project.TestItems.Current.ElementToBeRun.Caption
    • Kaloyan's avatar
      Kaloyan
      Occasional Contributor

      Hi Guys,

      This property TestItems.Current.ElementToBeRun.Caption returns the following string "KeywordTests - MyTestName" .
      Is there a way to get only MyTestName ?

      I can use some string manipulation but I just wonder if there is some kind of property that returns the name of currently running test.

      Also is there a way to get a reference to the local variables of Currently Running Keyword Test ?
      I read the articles in which people use JavaScript eval() function but I post are old so maybe there is some new way to do it more easy by using TC feature.

       

      Kind Regards

      ATQE Kaloyan Chipilev

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Because the caption is basically the same as what is being showin in your test item editor, there isn't an explicit way of getting just "MyTestName".  As mentioned, you need to parse that out via string.