Forum Discussion

cliffapi's avatar
cliffapi
Occasional Visitor
6 years ago

How to Set or Get "Test Step" Properties from another Test Case.

Hi. I am pulling my hair out. I have 2 test cases, the 1st one I created a "Properties" test step and I can set and get to that using Groovy within that test case.  I also have also created another ...
  • jsheph01's avatar
    6 years ago

    This will work if both of your test cases are in the same test suite. If they are in different test suites then you will need to define what suite you are working with.

     

    def tCase = testRunner.testCase.testSuite.getTestCaseByName("Global")
    def tStep = tCase.getTestStepByName("Global Properties")
    tStep.setPropertyValue("Property Name", "newValue")

    If you wont need to reuse the test case or test step property then you can do it all in one line.

    testRunner.testCase.testSuite.getTestCaseByName("Global").getTestStepByName("Global Properties").setPropertyValue("Property Name", "newValue")