Postman works:
In Postman, I use the below to generate the accessToken
. It works fine and I am able to run the subsequent requests.
{
"userLoginData": {
"email": "abc@abc.com",
"password": "abc"
}
}
Playwright, not working:
When I do a https://www.base64encode.org/
for the above email:password which is abc@abc.com:abc
I get an encoded value. I use that in my playwright.config.ts
file as
extraHTTPHeaders: {
"Authorization":"Basic SGHSDFGsfasdfasdf"
},
However, this isn't working when I run a test with a get (or any other) request. I am getting an error.
Error: expect(received).toBe(expected) // Object.is equality
Expected: 201
Received: 403
Here's my spec
code
import { test, expect } from "@playwright/test";
test("API Login", async ({ request, baseURL }) => {
const endPoint = `${baseURL}/users/all`;
const all_users = await request.get(endPoint, {
});
expect (all_users.status()).toBe(201);
expect (all_users.ok()).toBeTruthy();
console.log(all_users);
});