Forum Discussion

ABCDEFG's avatar
ABCDEFG
Contributor
14 years ago

Groovy: Code to Access TestStep Property

I am new to Groovy and using packages/classes from -http://www.soapui.org/apidocs/overview-summary.html

can someone help me to write a code piece in groovy for below thing-

Need to get Test step name and display it using msg box and using that i need to update another test step.

Appreciate your help in advance!

^Thanks

4 Replies

  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    ABCDEFG wrote:
    I am new to Groovy and using packages/classes from -http://www.soapui.org/apidocs/overview-summary.html

    can someone help me to write a code piece in groovy for below thing-

    Need to get Test step name and display it using msg box and using that i need to update another test step.

    Appreciate your help in advance!

    ^Thanks


    This would depend on what is the location of test step. Do you want to display/log the name of the test step of the groovy script or another test step?

    In either case, follow this technique:

    def proj = testRunner.testCase.testSuite.project ;
    def tsuite = testRunner.testCase.testSuite ;
    def tcase = testRunner.testCase ;
    log.info "Current Test Step is = ${tcase.getTestStepAt(2).getName()}"; //This will return the name of test step at index 2.
    log.info "Current Test Step is = ${tcase.getTestStepByName("Step_Name").getName()}"; //This will return the name of the indicated test step
  • Thank you Deepesh!

    Ok, using the name, I need to update another test step in the same test case/another test case

    Can you pls.

    2nd - I need to get 5 properties of a SOAP Request Test step. Could you!

    3rd - Can we have message box display as its for VB.Script [msg box()]

    ^Thanks
  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    ABCDEFG wrote:
    Thank you Deepesh!

    Ok, using the name, I need to update another test step in the same test case/another test case

    Can you pls.

    2nd - I need to get 5 properties of a SOAP Request Test step. Could you!

    3rd - Can we have message box display as its for VB.Script [msg box()]

    ^Thanks

    1. What do you need to update in the other test step? Are you looking to update the test step name itself or you want to add an assertion or something?

    2. I have no clue to this one. Not even sure what you mean here.

    3. I don't believe we can have a message box. Remember that this is groovy not VB.script. However, since groovy accepts all Java code, you can import Java libraries and use the classes and objects of Java to display a pop up. I am not sure however which ones you would need?

    Regards,
    Deepesh Jain
  • 1. Test step name - i need to update test step name of another test step.

    2. To get Header parameters of a request.

    3. executing this code {testRunner.testCase.testSuite.project.name} displayed a msgbox with project name. So, thought of checking - do we have any specific code for message box display in groovy

    ^Regards