Skip to content

Commit

Permalink
fix: comments and behavior inconsistent
Browse files Browse the repository at this point in the history
  • Loading branch information
canstand committed Mar 25, 2024
1 parent 3142582 commit d5329ff
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions run.go
Expand Up @@ -229,9 +229,9 @@ type RunOptions struct {
Stderr io.Writer
}

// Install does download the driver and the browsers. If not called manually
// before playwright.Run() it will get executed there and might take a few seconds
// to download the Playwright suite.
// Install does download the driver and the browsers.
//
// Use this before playwright.Run() or use playwright cli to install the driver and browsers
func Install(options ...*RunOptions) error {
driver, err := NewDriver(transformRunOptions(options))
if err != nil {
Expand All @@ -243,12 +243,19 @@ func Install(options ...*RunOptions) error {
return nil
}

// Run starts a Playwright instance
// Run starts a Playwright instance.
//
// Requires the driver and the browsers to be installed before.
// Either use Install() or use playwright cli.
func Run(options ...*RunOptions) (*Playwright, error) {
driver, err := NewDriver(transformRunOptions(options))
if err != nil {
return nil, fmt.Errorf("could not get driver instance: %w", err)
}
up2date, err := driver.isUpToDateDriver()
if err != nil || !up2date {
return nil, fmt.Errorf("please install the driver (v%s) and browsers first: %w", playwrightCliVersion, err)
}
connection, err := driver.run()
if err != nil {
return nil, err
Expand Down

0 comments on commit d5329ff

Please sign in to comment.