Thursday 30 April 2020

How to pass Path Parameter in RestAssured? InterviewQuestion for API Automation?




 
 
 
 
 
 
 
 
 
 
 
In the below example passYear is the path param and we can pass year to it using pathParam() method of restAssured
   
@Test
        public void validatePathParam()
{
            //save the parameter value to pass in the variable "year" of type String

            String year = "2017";

            //In resp we are saving the response of our request

            Response resp =
                    given().
                    pathParam("passYear", year).
                    when().
                    get("http://result.com/{passYear}/results.json");//this api is dummy

            //printing the response body from Get() api call

             System.out.println("************"+resp.getBody().asString()+"**************");
            //validating response status code
            assertEquals(resp.getStatusCode(),200);
           
        }
   

Note:
        The param() method will act like queryParam() with GET requests.
        The API used in Get() is a dummy one, so use real-time api while executing


Check below link on top Interview preparation:

SQL Query   Cucumber-BDD    Linux Commands    Maven   GIT 

TestNG@after@before

RestAPI

*************************************************

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions



No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...