Forum Discussion

shona123's avatar
New Contributor
9 years ago

groovy script to take session id from login test case and use it in other cases?

  • nmrao's avatar
    9 years ago


    In the groovy script, the previous step response can be read using below statement. Assuming the step name is step1, rename as per your need. Below script gets the sessionId and store it at test suite level (assuming that sessionId might needed across the test suite, if you want it for all suites, then you can even store it at project level, up to you).



    def groovyUtils = new context )

    holder = groovyUtils.getXmlHolder( "step1#Response" )

    def sessionId = holder.getNodeValue( "//*:result/*:Session" )

    context.testCase.testSuite.setPropertyValue('SESSION_ID', sessionId)


    Next step is to use the stored sessionId in various places: Property Expansion

    In the other steps except groovy:


    In the groovy step: