Use of the testrunner variable to get the response data of any specific teststep.
def request = testRunner.testCase.getTestStepByName( “myTestStepName” );
def responseData = request.getProperty( “Response” );
log.info(responseData.value)
To display the name of project, testsuite, testcase & teststep:
def project = context.testCase.testSuite.project
log.info(project.name + ” ” + project)
def testSuite = project.getTestSuiteAt(1) // 1 is the index number of testsuite
log.info(testSuite.name + ” ” + testSuite)
def testCase = testSuite.getTestCaseAt(0) // 0 is the index number of testcase
log.info(testCase.name + ” ” + testCase)
def testStep = testCase.getTestStepAt(7) // 7 is the index number of teststep
log.info(testStep.name + ” ” + testStep)
To count the number of testsuites, testcases, teststeps use the below code :
def project = context.testCase.testSuite.project
log.info(project.name + ” ” + project.testSuiteCount)
def testSuite = project.getTestSuiteAt(1)
log.info(testSuite.name + ” ” + testSuite.testCaseCount)
def testCase = testSuite.getTestCaseAt(0)
log.info(testCase.name + ” ” + testCase.testStepCount)
def testStep = testCase.getTestStepAt(7)
log.info(testStep.name + ” ” + testStep)
We can use the above code and put them into a loop (for/each) to iterate through all the elements. In below example, we iterate through all the test steps under a testcase :
for (int count in 0..<testCase.testStepCount)
{
log.info(testCase.getTestStepAt(count).getName() + ” is our testStep number ” + count)
log.info(“Is this test step disabled? : ” + testCase.getTestStepAt(count).isDisabled())
}
OR
( 0..<testStep1 ).each{
log.info(testCase.getTestStepAt(it).getName())
}
====================================================
Response Time
def ResponseTime = messageExchange.response.timeTaken
log.info "Time taken " + ResponseTime + "ms"
====================================================
log.info messageExchange.getRequestContent().toString()
====================================================