Skip to content

Add only-shell option to run options #518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion run.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ func (d *PlaywrightDriver) installBrowsers() error {
if d.options.Browsers != nil {
additionalArgs = append(additionalArgs, d.options.Browsers...)
}

if d.options.OnlyInstallShell {
additionalArgs = append(additionalArgs, "--only-shell")
}

cmd := d.Command(additionalArgs...)
cmd.Stdout = d.options.Stdout
cmd.Stderr = d.options.Stderr
Expand All @@ -228,7 +233,9 @@ type RunOptions struct {
// - Windows: %USERPROFILE%\AppData\Local
// - macOS: ~/Library/Caches
// - Linux: ~/.cache
DriverDirectory string
DriverDirectory string
// OnlyInstallShell only downloads the headless shell. (For chromium browsers only)
OnlyInstallShell bool
SkipInstallBrowsers bool
// if not set and SkipInstallBrowsers is false, will download all browsers (chromium, firefox, webkit)
Browsers []string
Expand Down
27 changes: 27 additions & 0 deletions run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ func TestRunOptionsRedirectStderr(t *testing.T) {
require.Contains(t, output, fmt.Sprintf("path=%s", driverPath))
}

func TestRunOptions_OnlyInstallShell(t *testing.T) {
if getBrowserName() != "chromium" {
t.Skip("chromium only")
return
}

driverPath := t.TempDir()
driver, err := NewDriver(&RunOptions{
DriverDirectory: driverPath,
Browsers: []string{getBrowserName()},
Verbose: true,
OnlyInstallShell: true,
})
require.NoError(t, err)
browserPath := t.TempDir()

err = os.Setenv("PLAYWRIGHT_BROWSERS_PATH", browserPath)
require.NoError(t, err)
defer os.Unsetenv("PLAYWRIGHT_BROWSERS_PATH")

err = driver.Install()
require.NoError(t, err)

err = driver.Uninstall()
require.NoError(t, err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a little uncertain on how I should be checking if only the shell browser is installed. I thought about checking through the logs like the test above does, but that could cause problems if upstream playwright repo changes how anything is logged.

}

func TestDriverInstall(t *testing.T) {
driverPath := t.TempDir()
driver, err := NewDriver(&RunOptions{
Expand Down
Loading