Forum Discussion

amarnath1234's avatar
amarnath1234
Contributor
6 years ago

HTML report issue.

I want to capture test information of Test cases,for that i designed script and able to print all test steps information for the corrosponding Test Case.now when tried to extend the script for method,statuscode and EndpointURL ,Igot 1 error which I am unable to fix.Please help.

attached error detail for references.

script detail:-

def testStepName
def method
def statusCode
def endpointURL

testCase.testStepList.each{
testStepName = it.name
method = it.getHttpRequest().getResponse().getMethod()
statusCode = it.testRequest.response.responseHeaders["#status#"][0]
endpointURL = it.getHttpRequest().getResponse().getURL()

log.info testStepName
log.info method
log.info statusCode
log.info endpointURL
}

  • Hi,

    in your script, you try to get the method, statusCode and endpointURL for each test step. But, expect Request_GlobalOffersAvailable_Flag that probably contains all these values, the other steps does not seem to have such info as they are Groovy step and DataSource steps.

     

    Try to separate the logic there, to get the values only for the proper step, with something like this:

     

    def testStepName
    def method
    def statusCode
    def endpointURL
    
    testCase.testStepList.each{
    testStepName = it.name
    if(testStepName == "Request_GlobalOffersAvailable_Flag") {
    	method = it.getHttpRequest().getResponse().getMethod()
    	statusCode = it.testRequest.response.responseHeaders["#status#"][0]
    	endpointURL = it.getHttpRequest().getResponse().getURL()
    	log.info method
    	log.info statusCode
    	log.info endpointURL
    }
    
    log.info testStepName
    }

     

  • KonstantinosLps's avatar
    KonstantinosLps
    Occasional Contributor

    Hi,

    in your script, you try to get the method, statusCode and endpointURL for each test step. But, expect Request_GlobalOffersAvailable_Flag that probably contains all these values, the other steps does not seem to have such info as they are Groovy step and DataSource steps.

     

    Try to separate the logic there, to get the values only for the proper step, with something like this:

     

    def testStepName
    def method
    def statusCode
    def endpointURL
    
    testCase.testStepList.each{
    testStepName = it.name
    if(testStepName == "Request_GlobalOffersAvailable_Flag") {
    	method = it.getHttpRequest().getResponse().getMethod()
    	statusCode = it.testRequest.response.responseHeaders["#status#"][0]
    	endpointURL = it.getHttpRequest().getResponse().getURL()
    	log.info method
    	log.info statusCode
    	log.info endpointURL
    }
    
    log.info testStepName
    }