Forum Discussion

joshuawww's avatar
13 years ago

How to get name of test steps at run time?

I want to modify content of requests at runtime:
First I need to get name of test step, but how can I get it ? If there are many steps under the test case. How to iterate to get the test step name?
Thanks

1 Reply

  • to iterate through all teststeps and get ther names you could do something like this:


    testRunner.testCase.testSuite.project.getTestSuiteByName('TestSuite 2').getTestCaseByName('TestCase 2').testSteps.each{
    log.info it.getKey()
    }


    this would give you the names TestStep 1 ... TestStep 5
    if the project looks like this

    Project
    TestSuite 1
    TestCase 1
    groovyscript (the script from above runs here)
    TestSuite 2
    TestCase 2
    TestStep 1
    TestStep 2
    TestStep 3
    TestStep 4
    TestStep 5