[BUG] Reuse authentication state does not work with electronApplication.
See original GitHub issueContext:
- Playwright Version: 1.15.0
- Operating System: Mac with M1 chip.
- Node.js version: v14.17.1
- Browser: electronApplication (chromium)
Code Snippet
const { test, expect } = require('@playwright/test');
const { _electron: electron } = require('playwright');
let electronApp = null;
test.beforeEach(async () => {
electronApp = await electron.launch({
executablePath: executablePath,
env: {
NODE_ENV: 'test',
},
});
});
test.only('Load auth state', async () => {
const appWindow = await electronApp.firstWindow(); // The window that contains the app.
const context = await electronApp.context();
// Persist authentication state
await context.storageState('authState.json');
});
The bug
Hi there
I am adding end to end tests to an electron app. First thing I wanted to test is to share authentication state between tests, so I just need to log in once.
On the documentation, I found an excellent guide showing how to do it link here.
Tried to reproduce that using electronApplication
class to get the context, but once I try context.storageState('pathTojsonFile')
I receive next error:
browserContext.storageState: Protocol error (Storage.getCookies): Browser context management is not supported.
I understand electronApplication
is under experimental support and perhaps the way of persisting and loading state might differ. If context.storageState
is not the way to go in this use case, can you please provide a way to persist and load localStorage
state?
P.S: Playwright is awesome, thanks for such a nice library.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Gotcha! tried this approach before for setting, but did not work, now I see I was missing the
.reload()
😅@dgozman your help it’s been enormous, thank you!!
Keep the good work on Playwright, loving it! 😃
We also have the same issue in our E2E test project.