I am using QAF api common step and getting null in getMessageBody(). Also printed headers, status etc and its returning proper values.
System.out.println("Status is:" + new RestTestBase().getResponse().getStatus().name());
System.out.println("Header is:" + new RestTestBase().getResponse().getHeaders());
System.out.println("Body is:" + new RestTestBase().getResponse().getMessageBody());
WsStep.responseShouldHaveValueContainsIgnoringCase(expectedvalue, jpath);
Output : Status is:OK Header is:{CF-RAY=[708ac4150dcfa03f-SIN], ..... charset=utf-8]} Body is:null
I have to use below method to get proper response.
public static void responseShouldHaveValueIgnoringCase(String expectedValue, String path) {
Object actual = JsonPath.read(new RestTestBase().getResponse().getMessageBody(), getPath(path));
assertThat(String.valueOf(actual), Matchers.equalToIgnoringCase(expectedValue));
}
Note: I am using below version and endup with null value. <qaf-support-ws.version>3.1.0</qaf-support-ws.version> and verified in <qaf-support-ws.version>3.0.1</qaf-support-ws.version> Moreover, morethan 9 globals were used this steps. JsonPath.read(new RestTestBase().getResponse().getMessageBody(), getPath(path));
Reference: https://github.com/qmetry/qaf-support-ws/blob/master/src/com/qmetry/qaf/automation/step/WsStep.java
I tried above using qaf-repository-editor and it works fine without issue. For validation step using xpath i have added following dependency in pom.
i tried following step and it worked fine.