Rayrun
← Back to Discord Forum

Different ways to login when application uses a refresh token

So i need a more optimized way to login and save storageState when the application is using a token to login and it expires after 5 minutes. I can't use the API to login so i need to login through the GUI. A bit more info about the login process, when i first login, the app creates a token, this token is then refreshed when clicking around on the page with another request. What i can understand if i save a sessions using storageState it will not use the updated cookie that sets when refresh token is executed.

So my question is how can I login in another way or how can I update storage state before each test? My code that im not happy with, because it logs in before each test (it becomes very slow, but it works...). I dont want to login before each test.

type TestFixtures = {
   ssn: string
   login: any,
};

export const test = baseTest.extend<TestFixtures>({
   ssn: "username",
   login: async ({ ssn, page }, use) => {
         await myLogin();
         await page.context().storageState({ path: `.auth/user.json`});
      }
      await use(page);
   },
});

Any help is appreciated, thanks!

This thread is trying to answer question "How can I login in another way or how can I update storage state before each test when the application uses a token to login that expires after 5 minutes?"

1 reply

Different ways to login when application uses a refresh token

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.