@@ -229,9 +229,9 @@ type RunOptions struct {
229
229
Stderr io.Writer
230
230
}
231
231
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
235
235
func Install (options ... * RunOptions ) error {
236
236
driver , err := NewDriver (transformRunOptions (options ))
237
237
if err != nil {
@@ -243,12 +243,19 @@ func Install(options ...*RunOptions) error {
243
243
return nil
244
244
}
245
245
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.
247
250
func Run (options ... * RunOptions ) (* Playwright , error ) {
248
251
driver , err := NewDriver (transformRunOptions (options ))
249
252
if err != nil {
250
253
return nil , fmt .Errorf ("could not get driver instance: %w" , err )
251
254
}
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
+ }
252
259
connection , err := driver .run ()
253
260
if err != nil {
254
261
return nil , err
0 commit comments