cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Occasional Visitor

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 "Properties" test step in the 2nd Test case and from within that Test Case (in Groovy) I want to Set a value in the 1st ones "Properties" test step, but cannot figure out how to do this. Any help would be appreciated, please. Thanks, Cliff.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Contributor

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

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")

View solution in original post

1 REPLY 1
Highlighted
Contributor

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

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")

View solution in original post