StorageState in the global-setup doesn't work
See original GitHub issueglobal-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:
- Created 10 months ago
- Comments:8 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Two moment are possible:
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
Authorisation in your app can work not rellaing on cookies
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!