Comments (9)
@joshmgrant Could you please share a full repro with us? I suspect this is related to cwd
when you run your tests. The robust solution is to provide an absolute path, for example:
import path from 'path';
test.use({ storageState: path.resolve(__dirname, '../../playwright/.auth/gmail.json') })
from playwright.
Here is my auth.setup.ts
file
import * as fs from 'node:fs';
import { test as setup } from '@playwright/test';
import { LoginPage } from './pages/login-page';
// TODO: replace with env vars
const gmailUser = 'some_user"
const outlookUser = 'some_other_user'
const password = process.env.E2E_USER_PASSWORD || ''
// following this approach for multiple user authenications
// https://playwright.dev/docs/auth#multiple-signed-in-roles
const outlookAuthFile = 'playwright/.auth/outlook.json';
setup.skip(fs.existsSync(outlookAuthFile)); // added this based on another ticket to fix the issue
setup('authenticate as Outlook user', async ({ page }) => {
// Perform authentication steps. Replace these actions with your own.
const loginPage = new LoginPage(page);
loginPage.loginAs(outlookUser, password);
await page.context().storageState({ path: outlookAuthFile });
});
const gmailAuthFile = 'playwright/.auth/gmail.json';
setup.skip(fs.existsSync(gmailAuthFile));
setup('authenticate as GMail user', async ({ page }) => {
const loginPage = new LoginPage(page);
loginPage.loginAs(gmailUser, password);
await page.context().storageState({ path: gmailAuthFile });
});
from playwright.
@joshmgrant Unfortunately, we cannot repro with just a single file. We need to run the whole example, so need the whole project.
Did you have a chance to try the absolute path suggestion?
from playwright.
Let me try the absolute path suggestion. I can see if I can get a repo but it might take some work.
from playwright.
Hello again. I tried an absolute file path and it doesn't seem to work. I'm also unable to share more than the config file above.
from playwright.
Hello again. I tried an absolute file path and it doesn't seem to work. I'm also unable to share more than the config file above.
In this case we won't be able to help, unfortunately. I'll leave this issue open for a few days, just in case you'd come up with a reproduction.
Looking at the snippet above, it seems like you'd skip both setup
s, for outlook and gmail, whenever any of the storage state files is present. I'd recommend to read about test.skip
in the documentation.
from playwright.
Related Issues (20)
- [Docs]: python docs: pressSequentially should be press_sequentially
- [Feature]: undeprecate the dev tools option. HOT 1
- [Bug]: Click on visible element fails due to timeout in visibility check HOT 1
- [Bug]: UI Mode - 1 minute very slow at start of ui mode due to watcher watching excessive files (esp. on windows) HOT 1
- [Bug]: .NET: certificate authentication not working when running tests.
- [Feature]: Removal of `mount()` inside `test.beforeEach()` and `test.afterAll()` HOT 5
- Receiving following error message "AxiosError: Request failed with status code 401" on request HOT 1
- [Docs]: Playwright webkit screenshot configuration HOT 6
- [Bug]: `Error: Playwright Test did not expect test() to be called here.` HOT 5
- [Bug]: Headers set in context.route are sent by the browsers but not available in the network tab in trace view on redirects HOT 1
- [Bug] Reusable browser clock bug
- [Bug] Check if Invalid time before sending to server
- [Bug]: npm run build-android-driver ,print error log:"cd: src/server/android/driver: No such file or directory" HOT 1
- [Bug]: no trace, video and screenshot in case of failed test (Target page, context or browser has been closed) HOT 13
- [Bug]: Playwright cannot click on a link inside a disabled input label
- [Docs]: Component testing "best practices" or "pitfalls" HOT 1
- URL redirection issue HOT 2
- [Docs]: Svelte Component Testing Hooks
- [Feature]: debug with ability to step through code for API testing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playwright.