Fast and easy authentication with Playwright #216
Replies: 8 comments
-
Thanks for sharing this, I found it very useful as a more fleshed-out example than what's provided in the Playwright docs. One thing I wanted to mention with regard to your site more broadly is that when I select text in your code snippets, if it is the "modified" code with the little vertical identifier alongside it, the highlight color is the same as the background color. Not sure if you will understand what I mean, but for instance this line:
Anyway, thanks again for sharing. |
Beta Was this translation helpful? Give feedback.
-
Thanks @lenymo - and thanks for letting me know about this, it seems like this is a quirk for the light-theme version. I'll take a look at it ASAP. |
Beta Was this translation helpful? Give feedback.
-
What if I do not want to use that stoageState.json to all the test? Where should I define exceptions for DO NOT USE it for a specific test, like cookies.test.ts? |
Beta Was this translation helpful? Give feedback.
-
@CsillaCsipak see https://timdeschryver.dev/blog/revamped-authentication-with-playwright |
Beta Was this translation helpful? Give feedback.
-
Beautiful work @timedeschryver, I have something similar to this. But I wanted to try the same auth details stored on the api, but not sure if it's possible or have you tried something similar? |
Beta Was this translation helpful? Give feedback.
-
I'm not sure what you're trying to do @MsingathiM, could you elaborate please? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response @timdeschryver so I’m trying to test an API endpoint which uses the same auth as the UI, and since logins are stored in the storage, I’m calling it from the storagestate before my api call. However it’s failing to authorise with a 401 status code. |
Beta Was this translation helpful? Give feedback.
-
Hmmmm, as far as I know @MsingathiM that should work 🤔 |
Beta Was this translation helpful? Give feedback.
-
Fast and easy authentication with Playwright - Tim Deschryver
Using the global setup feature from Playwright to authenticate a test user and reuse its authentication state throughout your test suite.
https://timdeschryver.dev/blog/fast-and-easy-authentication-with-playwright
Beta Was this translation helpful? Give feedback.
All reactions