diff --git a/playwright.go b/playwright.go index be19dce..b0992e8 100644 --- a/playwright.go +++ b/playwright.go @@ -63,6 +63,9 @@ type PlayWrightBrowserOptions struct { // DontLaunchOnConnectFailure will, if set, not launch the browser if the connection to the PlayWright server, // and return an error if the connection fails. DontLaunchOnConnectFailure bool + + // UseLocalOnly will, if set, not connect to the PlayWright server, and instead use the local PlayWright server. + UseLocalOnly bool } func cookieToPlaywrightOptionalCookie(cookie Cookie) playwright.OptionalCookie { @@ -119,6 +122,9 @@ func NewPlayWrightBrowser(opts ...PlayWrightBrowserOptions) (Browser, error) { if o.PlayWrightServerAddress != "" { opt.PlayWrightServerAddress = o.PlayWrightServerAddress } + if o.DontLaunchOnConnectFailure { + opt.DontLaunchOnConnectFailure = true + } opt.ShowBrowser = o.ShowBrowser } @@ -165,7 +171,7 @@ func NewPlayWrightBrowser(opts ...PlayWrightBrowserOptions) (Browser, error) { var browser playwright.Browser var launch = true - if opt.PlayWrightServerAddress != "" { + if opt.PlayWrightServerAddress != "" && !opt.UseLocalOnly { launch = false slog.Info("connecting to playwright server", "address", opt.PlayWrightServerAddress) var timeout float64 = 30000