cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Highlighted
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

New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to change request body before sending it to the server for the TechCorner tag!


Scripts created in June:
- A script to generate a request body based on data from Datasource
- A script to go through all response nodes and check the value of the required field
- A Dispatching script to get responses based on the values in Request Body
- A script to add a new tag and assign it to all TestCases in a TestSuite
Top Kudoed Authors