How to create a property using groovy script???
In my automation script i am in need to create a property and store the value dynamically ,so that the value stored is used in upcoming steps for further process,Could anyone help in this.
I tried online every article says on set and get property in groovy,but i need to create a property in groovy.
Solved! Go to Solution.
Anyways you can use set to create new properties
def testCaseProperty = testRunner.testCase.setPropertyValue("myTest", "blah")
Building on @sanj's reply, depending on how you need to access the property there may be a few considerations you need to make.
- If you need a property available across all test steps in a test case, store it at that test case level.
- def testCaseProperty = testRunner.testCase.setPropertyValue("myTest", "blah")
- (as provided by sanj)
- If you need a property available across all test cases in a test suite, store it at the test suite level.
- def testSuiteProperty = testRunner.testCase.testSuite.setPropertyValue("myTest", "blah")
- If you need a property available across all test suites in a project, store it at the project level.
- def projectProperty = testRunner.testCase.testSuite.project.setPropertyValue("myTest", "blah")
Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Here is the appeal to the author. Please be patient while posting the questions with sample reproducible data, context and clear details so that external people can understand what exact the issue being faced. The time spent explain this not only helps you, but also to the people who willing to help others. Better the question, better the answer.
Not sure where you searched online for the same, please refer below link which has more frequently used code snippets and I believe that is helpful to get started.
Thank you for the understanding and your cooperation.