0

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

user861594
  • 5,733
  • 3
  • 29
  • 45
Rafeek
  • 61
  • 6
  • Do you mean it works with qaf 3.0.1 but not working with 3.1.0? – user861594 May 09 '22 at 15:11
  • @user861594, I tried with lower version and upgraded with higher version, both were not working only for getMessageBody(). Same is working fine for getHeaders() and getStatus() etc.. Almost more than 9 globals were using getMessageBody() and all getting failed. https://github.com/qmetry/qaf-support-ws/blob/master/src/com/qmetry/qaf/automation/step/WsStep.java – Rafeek May 10 '22 at 04:17
  • make sure you are doing right request and the response returns body. Will you be able to share your request call? – user861594 Jun 01 '22 at 17:51
  • Hi @user861594, ` String responseBody = new RestTestBase().getResponse().getMessageBody(); System.out.println("the body is"+responseBody);` – Rafeek Nov 26 '22 at 20:57
  • I have attached console log screenshot in main thread. my sample request is http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso/ListOfContinentsByName Note: My query is why below code is not returning any value. Because this issue, unable to use common wsstep methods. String responseBody = new RestTestBase().getResponse().getMessageBody(); – Rafeek Nov 26 '22 at 21:08
  • AF Africa AN Antarctica AS Asia EU Europe OC Ocenania AM The Americas – Rafeek Nov 26 '22 at 21:16
  • To validate xml value you need to use steps for xpath. Steps with jsonpath are for validating json response body. – user861594 Nov 29 '22 at 18:43

1 Answers1

0

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

user861594
  • 5,733
  • 3
  • 29
  • 45