author avatar

rishav.raj

Mon Jul 31 2023

How to fetch and test those API endpoints which is accessible after login into the applications.

1. Launch the browser navigate to the login page using playwright
2. Enter the login credentials and submit the form to login.
3. After successful login, use playwright API to access the API endpoints.
4. Make API requests and assert the response to validate the functionality
Example of fetching API after login :



// implementation of login test

const apiEndpointURL = "https://example.com/api/endpoint";
const apiResponse = await page.evaluate(async (url) => {
      const response = await fetch(url);
      return await response.json()
}, apiEndpointURL)

console.log(apiResponse)


Thanks