出于 API 自动化目的,请使用放心。它易于学习,实施。您将能够完全自动化 api(JSON 和 XML)。所有验证将在几秒钟内完成。如果您集成 RestAssured 和 Selenium,您将能够使用 API 和前端验证数据。
如果您需要了解更多信息,请告诉我。
示例 GET 代码:-
RestAssured.baseURI="base url Eg :- https://www.google.com/";given().header("Accept","application/json").header("Authorization","Value").when().get("rest of the part of the url").then().assertThat().statusCode(200).and().contentType(ContentType.JSON).and().body("name[0]",equalTo("Location"));
示例 POST 代码:-
RestAssured.baseURI="https://www.google.com/";
Response res=given().header("Authorization","Value").header("cache-control","no-cache").header("content-type","application/json").body("{"+"\"format\":[\"live-blog\",\"video-story\",\"Photo Gallery\",\"photo-gallery\",\"blank\",\"breaking-news\",\"photo-story\"],"+"\"language\": \"english\""+"}").when().post("Rest of the url`enter code here`").
then().assertThat().statusCode(200).and().contentType(ContentType.JSON).extract().response();
String res_string= res.asString();
System.out.println(res_string);
JsonPath jpath = new JsonPath(res_string);
String articleid = jpath.get("[0].articleId");
System.out.println(articleid);
你可以在网上找到所有的jar文件。
为格式道歉。