verifyElementPropertyValue() always returns Null Pointer exception

kazurayam said:

But it fails for
println(“response.isXmlContentType()=” + response.isXmlContentType())

What do you mean “it fails for”? Do you get NullPointerException? or Do you see true or false is printed?

I get a NullPointerException

content type=null

This implies that your Application Under Test has a serious defect. It is not responding a HTTP Header “Content-Type”.

HTTP Header “Content-Type” is almost mandatory. Any HTTP clients, including Katalon Studio, would have hard time processing a HTTP response without appropriate “Content-Type” header.

As

tells you, you can now read the source code of verifyElementPropertyValue method at

In the 50 line you can find the following line:

      Object retValue = response.isXmlContentType() 

I believe isXmlContentType() method internally checks the Content-Type header of the response. In your case, the Content-Type is null. Therefore you always get NullPointerException.

I believe that the only way for you to fix NPE is to change your AUT so that it responds appropriate Content-Type header.

kazurayam said:

As

tells you, you can now read the source code of verifyElementPropertyValue method at

In the 50 line you can find the following line:

      Object retValue = response.isXmlContentType() 

I believe isXmlContentType() method internally checks the Content-Type header of the response. In your case, the Content-Type is null. Therefore you always get NullPointerException.

I believe that the only way for you to fix NPE is to change your AUT so that it responds appropriate Content-Type header.

Thanks . Will check with the developers.

To Katalon Team

Katalon Studio v5.9.1, com.kms.katalon.core.testobject.ResponseObject has following code:

public void setContentType(String contentType) {    this.contentType = contentType}

Now we are aware we may have errornious cases where the argument contentType is null.

I think this code should be changed as follows:

import java.util.Objectspublic void setContentType(String contentType) {    this.contentType = Objects.requireNonNull(contentType)}

To Katalon Team,

Katalon Studio v5.9.1, com.kms.katalon.core.testobject.ResponseObject has following code:

public void setContentType(String contentType) {    this.contentType = contentType}

Now we are aware we may have errornious cases where the argument contentType is null.

I think this code should be changed as follows:

import java.util.Objectspublic void setContentType(String contentType) {    this.contentType = Objects.requireNonNull(contentType)}
1 Like