From b0af949397664561cd143d72bf96844f69e81c24 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Mon, 18 Oct 2021 17:43:46 -0500 Subject: [PATCH] Use geckodriver directly without selenium --- main.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index d8b1282..86c6987 100644 --- a/main.go +++ b/main.go @@ -126,25 +126,23 @@ func main() { flag.Parse() const ( - // These paths will be different on your system. - seleniumPath = "deps/selenium-server-standalone-3.141.59.jar" geckoDriverPath = "deps/geckodriver" - seleniumPort = 8080 + geckoDriverPort = 8080 ) + opts := []selenium.ServiceOption{ - selenium.StartFrameBuffer(), // Start an X frame buffer for the browser to run in. - selenium.GeckoDriver(geckoDriverPath), // Specify the path to GeckoDriver in order to use Firefox. + selenium.StartFrameBuffer(), selenium.Output(nil), } selenium.SetDebug(true) - service, err := selenium.NewSeleniumService(seleniumPath, seleniumPort, opts...) + + service, err := selenium.NewGeckoDriverService(geckoDriverPath, geckoDriverPort, opts...) if err != nil { - panic(err) // panic is used only as an example and is not otherwise recommended. + panic(err) } defer service.Stop() - // Connect to the WebDriver instance running locally. - caps := selenium.Capabilities{"browserName": "firefox"} - wd, err := selenium.NewRemote(caps, fmt.Sprintf("http://localhost:%d/wd/hub", seleniumPort)) + + wd, err := selenium.NewRemote(nil, fmt.Sprintf("http://localhost:%d", geckoDriverPort)) if err != nil { panic(err) }