microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.47k stars 235 forks source link

[Bug]: Microsoft.Playwright.Program.Main arguments broken. #1765

Closed kababoom closed 3 years ago

kababoom commented 3 years ago

Playwright version

1.15

Operating system

No response

What browsers are you seeing the problem on?

No response

Other information

Dotnet 5.0 All OS

What happened? / Describe the bug

(#1655) fix breaks the from code program arguments like install: Microsoft.Playwright.Program.Main(new string[] {"install" });

https://github.com/microsoft/playwright-dotnet/commit/98e6bf3d1f66933f97a18412edc277249709e05d

The passed args are overwritten with line 44: args = Environment.GetCommandLineArgs();

Perhaps something like this to give have both options

string lineArguments = null; if (args.Length > 0) { lineArguments = string.Join(" ", args); } else { args = Environment.GetCommandLineArgs(); lineArguments = Environment.CommandLine.Replace(args[0], string.Empty); }

Code snippet to reproduce your bug

Microsoft.Playwright.Program.Main(new string[] {"install" });

Relevant log output

Options:
  -V, --version                          output the version number
  -h, --help                             display help for command

Commands:
  open [options] [url]                   open page in browser specified via -b, --browser
  codegen [options] [url]                open page and generate code for user actions
  install [options] [browser...]         ensure browsers necessary for this version of Playwright are installed
  install-deps [browser...]              install dependencies necessary to run browsers (will ask for sudo permissions)
  cr [options] [url]                     open page in Chromium
  ff [options] [url]                     open page in Firefox
  wk [options] [url]                     open page in WebKit
pavelfeldman commented 3 years ago

This should be fixed in the latest Playwright and the latest tool.