[Question] @playwright/test: is there still a way to override fixtures?
See original GitHub issuePrimarily, I’m trying to achieve one of the older methods of authentication, by overriding the context
/page
fixtures (as seen here). Been looking around for a bit, and can’t seem to find a nice way to do this with some of the latest fixture documentation.
Is there a 1:1 translation from that old method, to the current setup for fixtures? Specifically, getting access to browser
when creating a new fixture, and overriding context
/page
?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Advanced: fixtures | Playwright - CukeTest
This allows us to override the baseURL used by the page fixture in our tests using test. use . Fixtures can also be...
Read more >Playwright Fixtures | POM | Playwright Tutorial - part 35
In this video, with the help of playwright fixtures, we are going to reduce the page object model complexity.Chapters:0:00 Playwright Test ...
Read more >Playwright With TypeScript Tutorial | Part X | LambdaTest
Ever wondered what Playwright Fixtures are? Watch this video to learn the concept of Playwright Fixtures and how to implement them for the...
Read more >Playwright Test Fixtures - ProgramsBuzz
The playwright test will set up the page fixture, which will be used to navigate to the browser and tear it down after...
Read more >Playwright save storage state only for certain files
In that case when you are need other auth just overwrite it with keyword "use". It is described in playwright doc. https://playwright.dev/docs/test-fixtures
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
In one of my projects, I was able to override it like that:
Does this work for you?
Yup, that works! I’ve been working to make it a bit more flexible. Long story short, I use projects to run tests per credential set, and a worker fixture to do the login once per worker. Then, I override the
context
fixture to use that auth info. Here’s a simplified version of what I came up with, in case it might help others: