question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StorageState in the global-setup doesn't work

See original GitHub issue

global-setup works as expected. When test open up the URL, it goes back to the login page. I am not sure what I am doing wrong in my code. Can someone please help.

Playwright config file:

  globalSetup: require.resolve('./config/global-setup'),
  use: {
    storageState: 'storageState.json'
}

global setup:

const page = await browser.newPage();
 console.log('global setup test');
 await page.goto("URL", { waitForSelector: '#okta-signin-username' });
 await page.fill('#okta-signin-username', 'test');
 await page.click('#okta-signin-submit');
 await page.fill('#input', 'Password');
 await page.click('[value=Verify]');
 await page.context().storageState({ path: storageState });
 await browser.close();

test file:

await page.goto("URL");
await verifyActions.verifyElementEnabled('#page-header');

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
v-romantcommented, Nov 10, 2022

Two moment are possible:

  1. Just simple mistake, try to name your path in global setup as “storageState.json” instead of storageState and also check that location of saved file and file in config are the same

  2. Authorisation in your app can work not rellaing on cookies

0reactions
pavelfeldmancommented, Nov 14, 2022

We need more information to act on this report. As long as we can’t repro it, it is unlikely with can make progress with it. Allow me to close it, but please file a new one and link to this issue when you get back to it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Setting storageState in the global-setup doesn't ...
When storing the storageState in the globalSetup function, it doesn't apply it to the test file. (So, when I run the "basic test", ......
Read more >
One time authentication in playwright is giving issues
global-setup '), use: { // Tell all tests to load signed-in state from 'storageState.json'. storageState: 'storageState.json' } }; export ...
Read more >
Playwright config | Katarzyna Kmiotek
globalSetup defines the file that will be executed before the test suite, globalTeardown points to the file that will be executed once all...
Read more >
Playwright with Next-Auth and PrismaOverview - Echobind
Having our Admin and User defined in the global setup means we can make use of test.use({ storageState: 'file-path-to-storage' });. Our home ...
Read more >
Authentication in Playwright - Anandhi K - Medium
... to the global setup file. This file will be required and run before all the tests. ... Already we have generated storageState...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found