QAF : RestTestBase().getResponse().getMessageBody() return null in wsstep

99 views Asked by At

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 console log 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

1

There are 1 answers

0
user861594 On

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.


<!-- https://mvnrepository.com/artifact/commons-jxpath/commons-jxpath -->
        <dependency>
            <groupId>commons-jxpath</groupId>
            <artifactId>commons-jxpath</artifactId>
            <version>1.3</version>
            <exclusions>
                <exclusion>
                <groupId>com.mockrunner</groupId>
                </exclusion>
            </exclusions>
        </dependency>

i tried following step and it worked fine.

response has value "Asia" at xpath "//tContinent[sCode[contains(.,'AS')]]/sName"

console