Search code examples
javaxmlapinodesalm

list of ids - ALM API Automation


i am doing api automation of hp-alm using rest assured n java.For test cases with multiple runs, im getting the below response in xml format.I want to know the list of id attributes with its values.

enter image description here

RequestSpecification httpRequest10 = RestAssured.given().cookies(loginCookies).cookies(sessionCookies).queryParam("query", "{cycle-id["+cycleId+"];test-id["+testCaseId+"]}");

        Response testRunId = httpRequest10.request(Method.GET,"/qcbin/rest/domains/"+domain+"/projects/"+project+"/runs");
                String testRunIdResponseBody = testRunId.getBody().asString();
                //logger.info("testRunId Response Body is =>  " + testRunIdResponseBody);//test run details in xml format
                statusCode = testRunId.getStatusCode();
                //logger.info("The testRunId status code recieved: " + statusCode);
                String stepID= testRunId.xmlPath().from(testRunIdResponseBody).get("**.find {it.@Name == 'id'}.Value");
                List<String> runIds = testRunId.xmlPath().from(testRunIdResponseBody).getList("**.find {it.@Name == 'id'}.Value");
                logger.info("stepID"+stepID);

Using the above code im able to the first id but not list of ids


Solution

  • I suppose **.find should be replaced with **.findAll:

    List<String> runIds = testRunId.xmlPath().from(testRunIdResponseBody).getList("**.findAll {it.@Name == 'id'}.Value");