Skip to content
Merged
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
32 changes: 32 additions & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,38 @@ func NewSeleniumService(jarPath string, port int, opts ...ServiceOption) (*Servi
return s, nil
}

// NewSeleniumServiceV4 starts a Selenium V4 instance in the background.
func NewSeleniumServiceV4(jarPath string, port int, opts ...ServiceOption) (*Service, error) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if worths having a ServiceOption instead to set or not a kind of 'V4' flag. That would let use the same NewSeleniumService call

s, err := newService(exec.Command("java"), "/wd/hub", port, opts...)
if err != nil {
return nil, err
}
s.cmd.Args = append(s.cmd.Args, "-jar", jarPath)
if s.javaPath != "" {
s.cmd.Path = s.javaPath
}

var classpath []string
if s.htmlUnitPath != "" {
classpath = append(classpath, s.htmlUnitPath)
}
if s.geckoDriverPath != "" {
classpath = append(classpath, s.geckoDriverPath)
}
if s.chromeDriverPath != "" {
classpath = append(classpath, s.chromeDriverPath)
}
if len(classpath) > 0 {
s.cmd.Args = append(s.cmd.Args, "--ext", strings.Join(classpath, ":"))
}
s.cmd.Args = append(s.cmd.Args, "standalone", "--port", strconv.Itoa(port))
if err := s.start(port); err != nil {
return nil, err
}

return s, nil
}

// NewChromeDriverService starts a ChromeDriver instance in the background.
func NewChromeDriverService(path string, port int, opts ...ServiceOption) (*Service, error) {
cmd := exec.Command(path, "--port="+strconv.Itoa(port), "--url-base=wd/hub", "--verbose")
Expand Down