[Bug]: Remote browsers ignore the LaunchOptionsAsync override (x-playwright-launch-options is built from runsettings only)

Chiusa
#3,424 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #3455 di @dgozman — integrata

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp, playwright
Ambito
backend, testing

Direzione di ricerca

Read src/Playwright.NUnit/BrowserService.cs around lines 51–61 and 93, then compare the equivalent MSTest, Xunit, and Xunit.v3 copies. Trace how CreateBrowser receives LaunchOptionsAsync() and runsettings options, and check existing tests for remote connection headers. Done when remote launch options honor the class override with runsettings fallback and a caller-supplied header no longer causes a duplicate-key exception.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version

1.64.0, and main at d79328b

Steps to reproduce

In BrowserService.cs#L51-L61 (identical in the MSTest, Xunit and Xunit.v3 copies), the connect branch builds the header like this:

headers.Add("x-playwright-launch-options",
    JsonSerializer.Serialize(PlaywrightSettingsProvider.LaunchOptions, ...));

CreateBrowser receives the class's launchOptions (from LaunchOptionsAsync()) but doesn't use it here. The legacy PLAYWRIGHT_SERVICE_* path (BrowserService.cs#L93) does the same.

To reproduce:

  1. Override both ConnectOptionsAsync() (pointing at npx playwright run-server) and LaunchOptionsAsync() (e.g. Headless = false or Args = ["--user-agent=hello"]).
  2. Run a test that prints navigator.userAgent.
Expected behavior

The launch options sent to the remote server are the class's LaunchOptionsAsync() result when present, falling back to runsettings.

Actual behavior
  • The remote browser is launched with runsettings options only, so the override is silently dropped.
  • If the user already put an x-playwright-launch-options header in ConnectOptionsAsync, headers.Add throws ArgumentException ("An item with the same key has already been added").
Additional context

No response

Environment
- Operating System: any
- CPU: any
- Browser: All
- .NET Version (TFM): any
- Other info: found by code review of main @ d79328b
Lingua principale
C#
Stelle
3k
Fork
307
Merge medio
1g 14h
PR unite (30g)
32

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright-dotnet

Tutte le issue di microsoft/playwright-dotnet

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.