Skip to content

Commit 2fb5d39

Browse files
authored
fix: comments and behavior inconsistent (#446)
1 parent 3142582 commit 2fb5d39

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

run.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ type RunOptions struct {
229229
Stderr io.Writer
230230
}
231231

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

246-
// Run starts a Playwright instance
246+
// Run starts a Playwright instance.
247+
//
248+
// Requires the driver and the browsers to be installed before.
249+
// Either use Install() or use playwright cli.
247250
func Run(options ...*RunOptions) (*Playwright, error) {
248251
driver, err := NewDriver(transformRunOptions(options))
249252
if err != nil {
250253
return nil, fmt.Errorf("could not get driver instance: %w", err)
251254
}
255+
up2date, err := driver.isUpToDateDriver()
256+
if err != nil || !up2date {
257+
return nil, fmt.Errorf("please install the driver (v%s) and browsers first: %w", playwrightCliVersion, err)
258+
}
252259
connection, err := driver.run()
253260
if err != nil {
254261
return nil, err

0 commit comments

Comments
 (0)