Skip to content

support launchOptions with connectOptions on browser mode playwright #9660

@hi-ogawa

Description

@hi-ogawa

Clear and concise description of the problem

Currently using launchOptions for remote server with connectOptions is forbidden as per:

if (this.options.connectOptions) {
if (this.options.launchOptions) {
this.project.vitest.logger.warn(
c.yellow(`Found both ${c.bold(c.italic(c.yellow('connect')))} and ${c.bold(c.italic(c.yellow('launch')))} options in browser instance configuration.
Ignoring ${c.bold(c.italic(c.yellow('launch')))} options and using ${c.bold(c.italic(c.yellow('connect')))} mode.
You probably want to remove one of the two options and keep only the one you want to use.`),
)
}
const browser = await playwright[this.browserName].connect(this.options.connectOptions.wsEndpoint, this.options.connectOptions)
this.browser = browser
this.browserPromise = null
return this.browser
}

but playwright server supports setting remote browser launch option via x-playwright-launch-options header or launch-options query for initial wsEndpoint.

https://github.com/microsoft/playwright/blob/0bd37174dea4e6e681902100fb820cbbc537df68/packages/playwright-core/src/remote/playwrightServer.ts#L94-L103

Suggested solution

Reuse and apply existing launchOptions logic to connect(wsEndpoint) via launch-options=... query.

Alternative

No response

Additional context

While doing #9600, I partially confirmed launch-options works. Also it would be nice to run same browser test suite with wsEndpoint too.

Validations

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions