[Feature] `addInitScript` context option in `playwright.config.ts`
See original GitHub issuei’m trying to work around https://github.com/microsoft/playwright/issues/7008#issuecomment-927175899 as that solution no longer works, so i’m trying an init script instead:
test('test', async ({ page, context }) => {
await context.addInitScript(() => window._playwrightResume())
await page.goto('https://google.com/')
})
this doesn’t work, i assume because the page
was created before the context
was given the init script.
this works however, but it’s not ideal because it creates a new Page
when @playwright/test
has already created one
test('test', async ({ context }) => {
await context.addInitScript(() => window._playwrightResume())
const page = await context.newPage()
await page.goto('https://google.com/')
})
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7 (7 by maintainers)
Top Results From Across the Web
BrowserContext
Playwright allows creating "incognito" browser contexts with browser. ... The method adds a function called name on the window object of every frame...
Read more >Advanced: configuration | Playwright
To make use of this feature, we will declare an "option fixture" for the backend version, and use it in the tests. TypeScript;...
Read more >Use addInitScript in Playwright Internal With Examples
Learn how to use addInitScript function in Playwright Internal framework for your next JavaScript automation project with LambdaTest Automation Testing ...
Read more >Playwright before each for all spec files
First I have this in playwright/src/index.ts where I setup all the fixtures for ... addInitScript( { content } ); } await use( context...
Read more >playwright - test: cleanup proxy and context tests (#6085) - Gitnet
config /playwrightTest'; ... tests/browsercontext-add-init-script.spec.ts ... it('should use proxy', async ({ contextFactory, contextOptions, server }) => {.
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
Nah, so I mean something like this:
@DetachHead you can always override default
page
fixture with your implementation. Would it work?