diff --git a/playwright.go b/playwright.go index a503f06..2bcbcd1 100644 --- a/playwright.go +++ b/playwright.go @@ -30,7 +30,6 @@ func (p *Playwright) Launch(args []string) { log.Fatalf("could not start playwright: %v", err) } browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{ - Headless: playwright.Bool(false), Args: args, }) if err != nil { @@ -40,9 +39,9 @@ func (p *Playwright) Launch(args []string) { p.Browser = browser } -func (p *Playwright) LaunchCustomBrowser(args []string, browserPath string) { +func (p *Playwright) LaunchCustomBrowser(args []string, browserPath string, driver string) { runOptions := playwright.RunOptions{ - DriverDirectory: "./", + DriverDirectory: driver, SkipInstallBrowsers: true, Browsers: []string {browserPath}, } @@ -51,8 +50,8 @@ func (p *Playwright) LaunchCustomBrowser(args []string, browserPath string) { log.Fatalf("could not start playwright: %v", err) } browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{ - Headless: playwright.Bool(false), Args: args, + ExecutablePath: &browserPath, }) if err != nil { log.Fatalf("could not launch browser: %v", err) diff --git a/playwright_test.go b/playwright_test.go index b165692..c145ae3 100644 --- a/playwright_test.go +++ b/playwright_test.go @@ -31,7 +31,7 @@ func TestPlaywrightCustomBrowser(t *testing.T) { var opts2 playwright.PageGotoOptions var opts3 playwright.PageWaitForSelectorOptions - pw.LaunchCustomBrowser(opts, "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe") + pw.LaunchCustomBrowser(opts, "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe", "") pw.NewPage() pw.Goto("https://www.google.com", opts2) pw.WaitForSelector("//html/body/div[1]/div[2]", opts3)