[Bug]: BROWSER environment variable set by WSL or Linux desktops makes every test throw "Invalid browser name"

Aperta Adatta ai principianti
#3,426 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia da src/Playwright.TestAdapter/PlaywrightSettingsProvider.cs, in particolare dalla gestione delle variabili d'ambiente alle righe 59–65, e leggi i test che coprono la selezione del browser e runsettings. Riproduci il comportamento segnalato con BROWSER=wslview dotnet test. Il lavoro è terminato quando i valori di BROWSER non correlati non causano più errori nei test e i nomi dei browser supportati e la selezione tramite PLAYWRIGHT_BROWSER funzionano come previsto.

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

Descrizione

Version

1.64.0, and main at d79328b

Steps to reproduce
  1. On WSL (where BROWSER=wslview is a common setup) or on a Linux desktop with BROWSER=xdg-open / BROWSER=/usr/bin/firefox / BROWSER=google-chrome, run any NUnit/MSTest/xUnit PageTest.
  2. Or simply: BROWSER=wslview dotnet test.
Expected behavior

An unrelated BROWSER value (a path or a desktop launcher) is ignored, and the runsettings / default browser is used, as already happens for Codespaces' /vscode/... value.

Actual behavior

Every test fails with:

ArgumentException: Invalid browser name from 'BROWSER' environment variable.
Supported browsers: 'chromium', 'firefox', and 'webkit'
Actual browser: 'wslview'

PlaywrightSettingsProvider.cs#L59-L65 only ignores values starting with /vscode/. #3068 and #3181 fixed Codespaces and devcontainers one environment at a time.

Additional context

BROWSER is a widely used convention, read by Python's webbrowser, xdg, git, npm and others, so collisions are common.

Suggested fix:

  • Read PLAYWRIGHT_BROWSER first.
  • Only honor BROWSER when it is exactly chromium, firefox or webkit, and otherwise ignore it, perhaps with a one-line warning.
Environment
- Operating System: WSL2 / Linux desktop
- 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.