Forum Discussion

pkudrys's avatar
pkudrys
Contributor
2 months ago

how to get name of a keyword module started from another keyword module

Hi guys, is there a programmatic way to get the name of a keyword module, started from another keyword module? I need to identify a failing module in event handler. 

I'm aware of these methods, but all of them return only the name of main module, from which the child module was run (via Run Keyword Module):
Project.TestItems.Current.Name - returns name of the main keyword module
aqTestCase.CurrentTestCase.Name - returns name of the main keyword module
Project.TestItems.Current.ElementToBeRun.Caption - returns "KeywordTests -" +  name of the main keyword module

For now, I solved the problem by adding Set Variable Value action at start of every keyword module, which sets the project variable with hardcoded module name. But I don't like this solution, because it requires more steps and can cause potential failure in case the module name changes and someone forgets to change also the hardcoded string in given module.      

 

  • I've had a look through the documentation, and I don't think it's possible. The only solution I can think of, is what you already have.

     

3 Replies

  • What I did was have a standard to always put the CurrentTestCase.Name call inside each module at the top. Then each module knows its own name. I had it in a log message but you could leave that disabled and only enable it when you want it. 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I've had a look through the documentation, and I don't think it's possible. The only solution I can think of, is what you already have.

     

    • pkudrys's avatar
      pkudrys
      Contributor

      Thanks. Yes, I thought there is no other way. I will make another feature request ;)