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.

[BUG] Reuse authentication state does not work with electronApplication.

See original GitHub issue

Context:

  • 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:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
calcaidecommented, Oct 27, 2021

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! 😃

0reactions
GP-QAcommented, Oct 20, 2022

We also have the same issue in our E2E test project.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Doing work locally minimizes problems with Electron apps
In fact, I've played with the idea of providing an app that only sits in your menubar and runs the server, and opening...
Read more >
app | Electron
Control your application's event lifecycle.
Read more >
Desktop Applications in Electron: Pro Tips and Tricks
So Electron is a way to build desktop applications that run on Mac and Linux and ... And so if you do that...
Read more >
Build and Secure an Electron App - OpenID, OAuth, Node. ...
When using Auth0 for user authentication, you don't need to build login or sign-up forms. When your users click a login button in...
Read more >
Office 365 Desktop Apps with Angular 2 and Electron
I can't call my library “ADAL” because I'm not Microsoft and don't ... may not be a huge issue for desktop apps, but...
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