diff --git a/src/Playwright.TestAdapter/PlaywrightSettingsProvider.cs b/src/Playwright.TestAdapter/PlaywrightSettingsProvider.cs index 74dfb65560..0390535d79 100644 --- a/src/Playwright.TestAdapter/PlaywrightSettingsProvider.cs +++ b/src/Playwright.TestAdapter/PlaywrightSettingsProvider.cs @@ -40,7 +40,9 @@ public static string BrowserName get { var browserFromEnv = Environment.GetEnvironmentVariable("BROWSER")?.ToLowerInvariant(); - if (!string.IsNullOrEmpty(browserFromEnv)) + // GitHub Codespaces sets the BROWSER environment variable, ignore it if its bogus. + var ignoreValueFromEnv = Environment.GetEnvironmentVariable("CODESPACES") == "true" && browserFromEnv!.StartsWith("/vscode/"); + if (!string.IsNullOrEmpty(browserFromEnv) && !ignoreValueFromEnv) { ValidateBrowserName(browserFromEnv!, "'BROWSER' environment variable", "\nTry to remove 'BROWSER' environment variable for using default browser"); return browserFromEnv!;