Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion chromedriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"os/exec"
"strconv"
"time"

"github.com/phayes/freeport"
)

type ChromeSwitches map[string]interface{}
Expand All @@ -36,14 +38,17 @@ type ChromeDriver struct {
logFile *os.File
}

var rand_port = freeport.GetPort()

//create a new service using chromedriver.
//function returns an error if not supported switches are passed. Actual content
//of valid-named switches is not validate and is passed as it is.
//switch silent is removed (output is needed to check if chromedriver started correctly)
func NewChromeDriver(path string) *ChromeDriver {
d := &ChromeDriver{}
d.path = path
d.Port = 9515
// d.Port = 50386
d.Port = rand_port
d.BaseUrl = ""
d.Threads = 4
d.LogPath = "chromedriver.log"
Expand Down