<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Naveen Kaushal on Medium]]></title>
        <description><![CDATA[Stories by Naveen Kaushal on Medium]]></description>
        <link>https://medium.com/@erknaveen84?source=rss-e65f5224df7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*fnJuWrrfFMoDVqms.jpg</url>
            <title>Stories by Naveen Kaushal on Medium</title>
            <link>https://medium.com/@erknaveen84?source=rss-e65f5224df7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 15:04:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@erknaveen84/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Image Recognition in UI Testing: OpenCV as Selenium’s Visual Ally]]></title>
            <link>https://medium.com/@erknaveen84/image-recognition-in-ui-testing-opencv-as-seleniums-visual-ally-9f38a04c0431?source=rss-e65f5224df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f38a04c0431</guid>
            <dc:creator><![CDATA[Naveen Kaushal]]></dc:creator>
            <pubDate>Mon, 25 Aug 2025 07:13:51 GMT</pubDate>
            <atom:updated>2025-08-25T07:27:53.949Z</atom:updated>
            <content:encoded><![CDATA[<p>Test flakiness is a common challenge in Selenium-based automation, often arising from dynamic content, delayed element rendering, or changes in the Document Object Model (DOM). These issues can lead to elements being non-interactable or tests failing intermittently. To enhance the robustness of test scripts, integrating OpenCV — a powerful open-source computer vision library — can be beneficial.</p><p>OpenCV enables image-based recognition and processing, allowing testers to interact with web elements based on their visual representation rather than relying solely on traditional locators like IDs or XPaths. This approach is particularly useful when dealing with dynamic UIs or elements that lack stable identifiers. By capturing screenshots and using template matching techniques, OpenCV can identify and interact with UI components, effectively serving as a fallback mechanism when standard locator strategies fail.</p><p>Incorporating OpenCV into your Selenium framework not only mitigates issues related to test flakiness but also enhances the capability to perform visual validations. This integration ensures that your automated tests are more resilient and adaptable to changes in the application’s UI, leading to more reliable and maintainable test suites.</p><p>Below are some of the ways in which we can incorporate OpenCV in our automation frameworks.</p><p>If you are using a maven project, download the below dependency.</p><p>&lt;dependency&gt;<br> &lt;groupId&gt;org.openpnp&lt;/groupId&gt;<br> &lt;artifactId&gt;opencv&lt;/artifactId&gt;<br> &lt;version&gt;4.5.5–1&lt;/version&gt;<br> &lt;/dependency&gt;</p><p>Create below class in your projects util directory or depending on your framework. This class provides methods to Converts a BufferedImage to an OpenCV Mat object</p><pre>package framework.utils.openCV;<br><br>import org.opencv.core.CvType;<br>import org.opencv.core.Mat;<br><br>import java.awt.image.BufferedImage;<br><br>public class bufferedImage {<br><br>    // Convert BufferedImage to Mat (OpenCV format)<br>    public static Mat bufferedImageToMat(BufferedImage bi) {<br>        Mat mat = new Mat(bi.getHeight(), bi.getWidth(), CvType.CV_8UC3);<br><br>        // Convert BufferedImage to byte array<br>        int[] data = new int[bi.getWidth() * bi.getHeight()];<br>        bi.getRGB(0, 0, bi.getWidth(), bi.getHeight(), data, 0, bi.getWidth());<br><br>        // Convert to BGR format for OpenCV<br>        byte[] bData = new byte[bi.getWidth() * bi.getHeight() * 3];<br>        for (int i = 0; i &lt; data.length; i++) {<br>            int pixel = data[i];<br>            bData[i * 3] = (byte) (pixel &amp; 0xFF);         // B<br>            bData[i * 3 + 1] = (byte) ((pixel &gt;&gt; 8) &amp; 0xFF); // G<br>            bData[i * 3 + 2] = (byte) ((pixel &gt;&gt; 16) &amp; 0xFF); // R<br>        }<br>        mat.put(0, 0, bData);<br>        return mat;<br>    }<br>}</pre><pre> /**<br>     * Converts a BufferedImage to an OpenCV Mat object.<br>     *<br>     * This method performs the following steps:<br>     * 1. Creates a new Mat object with the same dimensions as the BufferedImage.<br>     * 2. Extracts the pixel data from the BufferedImage into an integer array.<br>     * 3. Converts the pixel data to the BGR format required by OpenCV.<br>     * 4. Populates the Mat object with the converted pixel data.</pre><p>Create a Method in your screenshot util class or depending on the structure of your project.</p><pre>public static ArrayList takeWebElementScreenshotUsingCVLibrary(WebDriver driver, WebElement element, String action, boolean success, Screen screen, Integer screenshotCounter) throws IOException {<br><br><br>    ArrayList&lt;Mat&gt; resultList = new ArrayList&lt;&gt;();<br>    // Get element location and size from Selenium<br>    Point elementLocation = element.getLocation();<br>    Dimension elementSize = element.getSize();<br><br>    // Take full page screenshot<br>    File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);<br>    BufferedImage fullScreenshot = ImageIO.read(screenshot);<br><br>    // Extract element region from screenshot to create template<br>    BufferedImage elementTemplate = fullScreenshot.getSubimage(elementLocation.getX(), elementLocation.getY(), elementSize.getWidth(), elementSize.getHeight());<br><br>    // Convert template to OpenCV Mat<br>    Mat templateMat = bufferedImage.bufferedImageToMat(elementTemplate);<br><br>    // Take another screenshot to search in (in case element moved)<br>    File searchScreenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);<br>    BufferedImage searchImage = ImageIO.read(searchScreenshot);<br>    Mat searchMat = bufferedImageToMat(searchImage);<br><br>    // Find element using template matching<br>    resultList.add(searchMat);<br>    resultList.add(templateMat);<br>    //org.opencv.core.Point foundLocation = findElementWithTemplateMatching.findElementWithTemplateMatching(searchMat, templateMat);<br><br>    return resultList;<br><br>}</pre><pre>Captures screenshots of a web element using OpenCV and Selenium, and returns a list of OpenCV Mat objects.<br>* <br>* This method performs the following steps:<br>* 1. Captures a full-page screenshot using Selenium.<br>* 2. Extracts the region of the web element from the screenshot.<br>* 3. Converts the extracted region into an OpenCV Mat object.<br>* 4. Captures another full-page screenshot to use as a search image.<br>* 5. Converts the second screenshot into an OpenCV Mat object.<br>* 6. Returns a list containing the search image Mat and the template</pre><p>Now add method to find web element with template matching</p><pre>public Point findElementWithTemplateMatching(Mat image, Mat template) {<br>    try {<br>        // Create result matrix<br>        int resultCols = image.cols() - template.cols() + 1;<br>        int resultRows = image.rows() - template.rows() + 1;<br><br>        if (resultCols &lt;= 0 || resultRows &lt;= 0) {<br>            System.out.println(&quot;Template is larger than search image&quot;);<br>            return null;<br>        }<br><br>        Mat result = new Mat(resultRows, resultCols, CvType.CV_32FC1);<br><br>        // Perform template matching<br>        Imgproc.matchTemplate(image, template, result, Imgproc.TM_CCOEFF_NORMED);<br><br>        // Find best match<br>        Core.MinMaxLocResult mmr = Core.minMaxLoc(result);<br><br>        // Check if match is good enough<br>        double threshold = 0.7; // Adjust based on your needs<br>        if (mmr.maxVal &gt;= threshold) {<br>            org.opencv.core.Point matchLoc = mmr.maxLoc;<br>            System.out.println(&quot;Element found at: (&quot; + (int) matchLoc.x + &quot;, &quot; + (int) matchLoc.y + &quot;)&quot;);<br>            System.out.println(&quot;Match confidence: &quot; + String.format(&quot;%.2f&quot;, mmr.maxVal * 100) + &quot;%&quot;);<br>            return matchLoc;<br>        } else {<br>            System.out.println(&quot;No good match found. Best match confidence: &quot; + String.format(&quot;%.2f&quot;, mmr.maxVal * 100) + &quot;%&quot;);<br>        }<br><br>    } catch (Exception e) {<br>        e.printStackTrace();<br>    }<br><br>    return null;<br>}</pre><pre>/**<br> * Finds the location of a template image within a larger image using OpenCV&#39;s template matching.<br> *<br> * This method performs the following steps:<br> * 1. Calculates the dimensions of the result matrix based on the input image and template sizes.<br> * 2. Checks if the template is larger than the search image and returns null if so.<br> * 3. Performs template matching using the TM_CCOEFF_NORMED method.<br> * 4. Identifies the best match location and its confidence score.<br> * 5. Returns the match location if the confidence score meets the threshold; otherwise, logs a message.</pre><pre>ArrayList&lt;Mat&gt; arrayList = ScreenshotUtil.takeWebElementScreenshotUsingCVLibrary(driver, bankProjectLink, &quot;Click Bank Project Link&quot;, true, screen, ScreenshotCounter);</pre><pre>        Point point = findElementWithTemplateMatching(arrayList.get(0), arrayList.get(1));</pre><pre>clickAtCoordinates((int) (point.x + arrayList.get(1).width() / 2), (int) (point.y + arrayList.get(1).height() / 2));</pre><p>Matched location is now used to click on any Web element.</p><pre>protected void clickAtCoordinates(int x, int y) {<br>    try {<br>        JavascriptExecutor js = (JavascriptExecutor) driver;<br><br>        // Create JavaScript to click at coordinates<br>        String script = String.format(&quot;var element = document.elementFromPoint(%d, %d); &quot; + &quot;if (element) { &quot; + &quot;  var event = new MouseEvent(&#39;click&#39;, { &quot; + &quot;    view: window, &quot; + &quot;    bubbles: true, &quot; + &quot;    cancelable: true &quot; + &quot;  }); &quot; + &quot;  element.dispatchEvent(event); &quot; + &quot;  console.log(&#39;Clicked on element at coordinates: %d, %d&#39;);&quot; + &quot;} else { &quot; + &quot;  console.log(&#39;No element found at coordinates: %d, %d&#39;);&quot; + &quot;}&quot;, x, y, x, y, x, y);<br><br>        js.executeScript(script);<br>        System.out.println(&quot;Clicked at coordinates: (&quot; + x + &quot;, &quot; + y + &quot;)&quot;);<br><br>        Thread.sleep(10000);<br>    } catch (Exception e) {<br>        System.out.println(&quot;Failed to click using JavaScript, trying direct click:&quot;);<br>        e.printStackTrace();<br><br>        // Fallback: Direct element click<br>        try {<br>            // Find element at coordinates using Selenium<br>            JavascriptExecutor js = (JavascriptExecutor) driver;<br>            String elementScript = String.format(&quot;return document.elementFromPoint(%d, %d);&quot;, x, y);<br><br>            Object element = js.executeScript(elementScript);<br>            if (element != null) {<br>                // This approach requires getting the element reference back to Selenium<br>                // For now, we&#39;ll use a different approach<br>                System.out.println(&quot;Element found at coordinates, but direct click not implemented&quot;);<br>            }<br>        } catch (Exception ex) {<br>            ex.printStackTrace();<br>        }<br>    }<br>}</pre><pre>/**<br> * Clicks at specific screen coordinates using JavaScript.<br> *<br> * This method performs the following steps:<br> * 1. Executes a JavaScript snippet to simulate a mouse click at the specified coordinates.<br> * 2. Logs the action to the console.<br> * 3. Waits for 10 seconds after the click.<br> * 4. If the JavaScript click fails, attempts a fallback to find the element at the coordinates using Selenium.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f38a04c0431" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Power of Rest Assured Library to automate API faster]]></title>
            <link>https://medium.com/@erknaveen84/power-of-rest-assured-library-to-automate-api-faster-f71bbfc06b1f?source=rss-e65f5224df7------2</link>
            <guid isPermaLink="false">https://medium.com/p/f71bbfc06b1f</guid>
            <dc:creator><![CDATA[Naveen Kaushal]]></dc:creator>
            <pubDate>Fri, 20 Dec 2024 06:51:39 GMT</pubDate>
            <atom:updated>2024-12-20T06:51:39.030Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we will learn how to use the Rest Assured Library to automate API flows, process requests and responses using filters, run test cases with TestNG, and view test results with Extent Reports. Rest Assured is a lightweight library that helps automate flows quickly with its English-like structure. Assertions are also powerful with rest assured ,can verify status code, status line, cookies, headers, content type and body.</p><h3><strong>Guide to setup Automation Framework to Automate APIs</strong></h3><p>To Setup the Framework, follow these steps:</p><p>· <strong>Create a Maven Project</strong>: Use IntelliJ IDEA or any other IDE and select the desired JDK version.</p><p>· <strong>Download Dependencies</strong>: Add the dependencies for TestNG, Extent Reports, and Rest Assured in your pom.xml file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*a6pilXzr5t3n3iGRaAlAHQ.png" /></figure><h3><strong>Project Structure</strong></h3><p><strong>Create Packages as per below Packages details.</strong></p><p><strong>BaseTest</strong>: Contains base classes for test setup and teardown.</p><p><strong>Tests.TestCase</strong>: Contains test cases for various features.</p><p><strong>Tests.Features:</strong> Contains feature-specific test flows.</p><p><strong>Utils</strong>: Contains utility classes for logging, reporting, and custom filters.</p><p><strong>Entity </strong>: POJO ( Plain Old Java Object)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*8bcyUw7_4OAw8VqZP3lZ1g.png" /></figure><p><strong>Dependencies</strong></p><p>Add below dependencies in pom.xml</p><p>The project uses the following dependencies:</p><p>io.rest-assured:rest-assured: For REST API testing.</p><p>com.aventstack:extentreports: For generating test reports.</p><p>org.testng:testng: For test execution.</p><p><strong>pom.xml</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*JmMWT-ROCgFYINiM7MnKQw.png" /></figure><p><strong>Key Classes and Their Functions</strong></p><p><strong>BaseTest.BaseTest</strong></p><p>This class provides the base setup and teardown methods for the tests. It initializes the ExtentReports instance for logging.</p><p>Below is the code for the Base Test</p><pre>package BaseTest;<br><br>import Utils.ExtentManager;<br>import Utils.createExecutionReports;<br>import com.aventstack.extentreports.ExtentReports;<br>import com.aventstack.extentreports.ExtentTest;<br>import com.aventstack.extentreports.markuputils.ExtentColor;<br>import com.aventstack.extentreports.markuputils.MarkupHelper;<br>import org.testng.ITestResult;<br>import org.testng.annotations.*;<br><br>import java.io.File;<br><br>public class BaseTest {<br><br>    protected ExtentManager extentManager;<br>    protected ExtentReports reports;<br>    protected ExtentTest extentTest;<br><br>    /**<br>     * Initializes the ExtentReports instance before the test suite starts.<br>     */<br>    @BeforeSuite<br>    public void initialize() {<br>        // Create a folder for the execution reports<br>        File reportFolder = createExecutionReports.createReportFolder();<br><br>        // Initialize the ExtentManager and create the ExtentReport<br>        extentManager = new ExtentManager();<br>        reports = extentManager.createExtentReport(reportFolder);<br>    }<br><br>    /**<br>     * Captures the test result after each test method and logs it to the ExtentReport.<br>     *<br>     * @param result The result of the test execution.<br>     */<br>    @AfterMethod<br>    public void tearDown(ITestResult result) {<br><br>        if (extentTest == null) {<br>            throw new IllegalArgumentException(&quot;ExtentTest instance cannot be null&quot;);<br>        }<br><br>        if (result.getStatus() == ITestResult.FAILURE) {<br>            String exceptionMessage = result.getThrowable().getMessage();<br>            extentTest.fail(MarkupHelper.createLabel(&quot;Test Case Failed&quot;, ExtentColor.RED)).fail(exceptionMessage);<br>        } else if (result.getStatus() == ITestResult.SUCCESS) {<br>            extentTest.pass(MarkupHelper.createLabel(&quot;Test Case Passed&quot;, ExtentColor.GREEN));<br>        }<br>    }<br><br>    /**<br>     * Flushes the ExtentReports instance to generate the HTML report.<br>     */<br>    @AfterSuite<br>    public void flush() {<br>        extentManager.flush();<br>    }<br>}</pre><p><strong>Tests.TestCase.tests</strong></p><p>This class contains the test cases. It includes a test method testPostMethod that initializes and executes a POST request flow.This is an example of a test case that sends a POST request and logs the details using ExtentReports.</p><pre>package Tests.TestCase;<br><br>import BaseTest.BaseTest;<br>import Tests.Features.createPostFlow;<br>import com.aventstack.extentreports.ExtentTest;<br>import org.testng.annotations.BeforeClass;<br>import org.testng.annotations.Test;<br><br>public class tests extends BaseTest {<br><br><br>    @BeforeClass<br>    public void initExtent() {<br>        extentTest = reports.createTest(&quot;[&quot; + &quot;Smoke&quot; + &quot;] PostMethod -Flow&quot;);<br>    }<br><br>    /**<br>     * Test method for sending a POST request.<br>     */<br>    @Test<br>    public void testPostMethod() {<br>        // Initialize createPostFlow and send the POST request<br>        createPostFlow flow = createPostFlow.init();<br>        flow.postMethod(extentTest);<br>    }<br><br><br>}</pre><p><strong>Tests.Features.createPostFlow</strong></p><p>This class handles the creation and execution of POST request flows.</p><pre>package Tests.Features;<br><br>import Tests.Entity.postJsonData;<br>import com.aventstack.extentreports.ExtentTest;<br>import io.restassured.RestAssured;<br>import io.restassured.builder.RequestSpecBuilder;<br>import io.restassured.http.ContentType;<br>import io.restassured.response.Response;<br>import io.restassured.specification.RequestSpecification;<br><br>public class createPostFlow {<br><br>    /**<br>     * Initializes a new instance of createPostFlow.<br>     *<br>     * @return A new instance of createPostFlow.<br>     */<br>    public static createPostFlow init() {<br>        return new createPostFlow();<br>    }<br><br>    /**<br>     * Sends a POST request to create a new post.<br>     *<br>     * @param extentTest The ExtentTest instance for logging.<br>     */<br>    public void postMethod(ExtentTest extentTest) {<br><br>        if (extentTest == null) {<br>            throw new IllegalArgumentException(&quot;ExtentTest instance cannot be null&quot;);<br>        }<br>        // Build the request specification<br>        RequestSpecBuilder requestSpecBuilder = new RequestSpecBuilder();<br>        requestSpecBuilder.setBaseUri(&quot;https://fakerestapi.azurewebsites.net&quot;);<br>        requestSpecBuilder.setContentType(ContentType.JSON);<br>        requestSpecBuilder.setBasePath(&quot;/api/v1/Activities&quot;);<br>        requestSpecBuilder.addHeader(&quot;accept&quot;,&quot;text/plain&quot;);<br>        requestSpecBuilder.setBody(new postJsonData());<br>        RequestSpecification requestSpecification = requestSpecBuilder.build();<br><br>        // Send the POST request and validate the response<br>        Response response = RestAssured<br>                .given()<br>                .log()<br>                .all()<br>                .spec(requestSpecification)<br>                .filter(new Utils.CustomerFilterRequest(extentTest))<br>                .filter(new Utils.customFilterResponse(extentTest))<br>                .post()<br>                .then()<br>                .statusCode(200)<br>                .log()<br>                .all()<br>                .extract()<br>                .response();<br>    }<br>}<br></pre><p><strong>Utils.CustomerFilterRequest</strong></p><p>This class implements a custom filter for logging request details using ExtentReports.</p><pre>package Utils;<br><br>import com.aventstack.extentreports.ExtentTest;<br>import com.aventstack.extentreports.Status;<br>import com.aventstack.extentreports.markuputils.MarkupHelper;<br>import io.restassured.filter.Filter;<br>import io.restassured.filter.FilterContext;<br>import io.restassured.response.Response;<br>import io.restassured.specification.FilterableRequestSpecification;<br>import io.restassured.specification.FilterableResponseSpecification;<br><br>public class CustomerFilterRequest implements Filter {<br><br>    private ExtentTest extentTest;<br><br>    /**<br>     * Constructor to initialize the ExtentTest instance.<br>     *<br>     * @param extentTest The ExtentTest instance for logging.<br>     */<br>    public CustomerFilterRequest(ExtentTest extentTest) {<br>        this.extentTest = extentTest;<br>    }<br><br>    @Override<br>    public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {<br>        // Log the request headers and body<br>        if (extentTest != null) {<br>            extentTest.log(Status.INFO, MarkupHelper.createCodeBlock(&quot;Request Headers: \n&quot; + requestSpec.getHeaders().toString()));<br>            extentTest.log(Status.INFO, MarkupHelper.createCodeBlock(&quot;Request Body: \n&quot; + requestSpec.getBody()));<br>        }<br>        // Proceed with the request and get the response<br>        Response response = ctx.next(requestSpec, responseSpec);<br>        // Log the response details<br>  //      if (extentTest != null) {<br>    //        extentTest.log(Status.INFO, MarkupHelper.createCodeBlock(&quot;Response: \n&quot; + response.asString()));<br>      //  }<br>        return response;<br>    }<br>}</pre><p><strong>Utils.customFilterResponse</strong></p><p>This class implements a custom filter for logging response details using ExtentReports.</p><pre>package Utils;<br><br>import com.aventstack.extentreports.ExtentTest;<br>import com.aventstack.extentreports.Status;<br>import com.aventstack.extentreports.markuputils.MarkupHelper;<br>import io.restassured.filter.Filter;<br>import io.restassured.filter.FilterContext;<br>import io.restassured.response.Response;<br>import io.restassured.specification.FilterableRequestSpecification;<br>import io.restassured.specification.FilterableResponseSpecification;<br><br>public class customFilterResponse implements Filter {<br>    private ExtentTest extentTest;<br><br>    /**<br>     * Constructor to initialize the ExtentTest instance.<br>     *<br>     * @param extentTest The ExtentTest instance for logging.<br>     */<br>    public customFilterResponse(ExtentTest extentTest) {<br>        this.extentTest = extentTest;<br>    }<br><br>    @Override<br>    public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {<br>        // Log the response details<br>        Response response = ctx.next(requestSpec, responseSpec);<br>        extentTest.log(Status.INFO, MarkupHelper.createCodeBlock(&quot;Response: \n&quot; + response.asString()));<br><br><br>        return response;<br>    }<br>}</pre><p><strong>Utils.createExecutionReports</strong></p><p>This class provides methods for creating directories to store execution reports.</p><pre>package Utils;<br><br>import java.io.File;<br>import java.text.SimpleDateFormat;<br>import java.util.Date;<br><br>public class createExecutionReports {<br><br>    /**<br>     * Generates a folder name based on the current date and time.<br>     *<br>     * @return The generated folder name.<br>     */<br>    public static String getExecutionFolderName() {<br>        Date date = new Date();<br>        SimpleDateFormat dateFormat = new SimpleDateFormat(&quot;yyyy-MM-dd_HH-mm-ss&quot;);<br>        String dateTimeString = dateFormat.format(date);<br>        return &quot;Execution-&quot; + dateTimeString;<br>    }<br><br>    /**<br>     * Creates a folder for storing execution reports.<br>     *<br>     * @return The created report folder.<br>     */<br>    public static File createReportFolder() {<br>        String executionFolderName = getExecutionFolderName();<br>        File reportFolder = new File(&quot;./EXECUTION_REPORTS/&quot; + executionFolderName);<br>        if (!reportFolder.exists()) {<br>            reportFolder.mkdirs();<br>        }<br>        return reportFolder;<br>    }<br>}</pre><p>Run the Tests class as TestNG.</p><p><strong>Generating Reports</strong></p><p>The test reports are generated in the ./EXECUTION_REPORTS/ directory. Each test run creates a new folder with a timestamp.</p><p><strong>Extent Report:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C6fETyWVmPV62D14Tb5Mbg.png" /></figure><p>We can put assertions for the verification of API Response.</p><pre>Response response = RestAssured.given()<br>        .spec(requestSpecification)<br>        .log()<br>        .all()<br>        .get()<br>        .then()<br>        .log()<br>        .all()<br>        .assertThat()<br>        .statusCode(200)<br>        .body(&quot;page&quot;, equalTo(2))<br>        .body(&quot;data.first_name&quot;, hasItems(&quot;Michael&quot;, &quot;Lindsay&quot;))<br>        .body(&quot;data.first_name[2]&quot;, equalTo(&quot;Tobias&quot;))<br>        .extract()<br>        .response();</pre><p>Thank you for taking the time to read this guide.Your feedback is always appreciated!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f71bbfc06b1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>