I have a Playwright test suite, in which we get the user token from storage state (JSON file) to call API requests for some actions that cannot be performed in the UI.
The problem is that the user token only lasts for an hour and we have failing API requests when the test suites takes more than an hour to run. However, the tests through UI with the same user don't fail - I suspect that the token is automatically refreshed when user keeps clicking on the UI. We cannot login through API, because there should be only one valid session at the same time. We tried to save the storage again to see whether we can store the refreshed token, but it did not work out when UI tests are working fine and endpoint is failing due to expired session.
Is there anyway that I can mitigate the problem from Playwright? We submitted a request to development team to extend the token on test environment, but it takes too long due to prioritization.
This thread is trying to answer question "Is there any way to mitigate the problem of short-lived user tokens in Playwright test suite?"
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email firstname.lastname@example.org.