Abhijit
Abhijit

Reputation: 1

How to handle Multiple Base Path in RestAssured API Testing Framework?

In my case, I have multiple Base basePath.

Eg: Base URI- > http://reg10xx.cwx.local/API/Admin

  BasePath1->/User

 EndPoint->/List

The problem arises here.

Base URI-> http://reg10xx.cwx.local/API/Admin

BasePath2->/Organisation

 EndPoint->/Roles.

Here is my case problem is with BasePath 1 and Base Path 2.

As in TestBase.java Class in Before Suite I have used

RestAssured.baseURI = configProperties.getBaseURI();
RestAssured.basePath = configProperties.getBasePath();

now I want to set my 2nd base path then is there any solution to this?

Upvotes: 0

Views: 2367

Answers (2)

Sameera De Silva
Sameera De Silva

Reputation: 1980

I am not sure what is yourbaseurl it , but you can parameterize yhe baseurl . Then in Basepath mention the path which is common for both Admin and roles . After that pass the path which completes the URI example -roles

import io.restassured.RestAssured;
import io.restassured.response.Response;

    RestAssured.baseURI = "http://reg10xx.cwx.local/";
    RestAssured.basePath = "API;


    Response admin= get("Admin");
    Response roles= get("Roles");

Upvotes: 0

nagesh kumar
nagesh kumar

Reputation: 11

One solution I can think of here is to set the base URL path at the test case/helper method level rather than setting it at the class level.

Example:

RequestSpecBuilder build;
build = new RequestSpecBuilder();
build.setBaseUri ("https://maps.googleapis.com");

Upvotes: 1

Related Questions