jsoup is a Java library for extracting HTML documents and getting the details from HTML DOM. jsoup uses DOM, CSS, and jQuery-like methods to retrieve information from any web page. Even though jsoup is mainly used for HTML document parsing, in our application we will use it for API testing.
First, we will call the REST API in jsoup and convert the result to JSON. To convert strings to JSON we will use the Gson library.
For both jsoup and Gson libraries, we may have to add dependencies in our pom.xml
. The following is the code for both jsoup and Gson dependencies:
<dependency> <groupId>org.jsoup</groupId> <artifactId>jsoup</artifactId> <version>1.8.2</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.2</version> </dependency>
We will use the jsoup REST consumer inside...