Forum Discussion

spartanhooah's avatar
spartanhooah
Occasional Contributor
8 years ago

getContentAsXml() gives null pointer

I have a fairly simple test case with three test steps:

  1. Groovy script that acts as a driver, calling the other two steps as necessary.
  2. Request step A
  3. Request step B

The driver calls request step A, does some processing, then calls step B. If I run the driver by itself, everything is fine. But if I execute the test case, the driver crashes when trying to parse the response from step A. Here is how I'm getting the response content:

 

responseXml = testRunner.runTestStepByName("MarketTimeRequest").getResponse()
responseBody = new XmlSlurper().parseText(responseXml.getContentAsXml()).Body

When I run the test case, I get a NullPointerException at responseXml.getContentAsXml(), with the message "Cannot invoke ... on null object". Why would the responseXml be null when running the test case, but not when running the driver?

  • spartanhooah's avatar
    spartanhooah
    Occasional Contributor

    I tried to run my driver script from Java by following the steps here, but I end up with the same error, even though from Java I'm running a single test step vs the whole test case. Please help.