Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NewSeleniumServiceV4 to support cli args for selenium version 4 #275

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
31 changes: 31 additions & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,37 @@ func NewSeleniumService(jarPath string, port int, opts ...ServiceOption) (*Servi
return s, nil
}

func NewSeleniumServiceV4(jarPath string, port int, opts ...ServiceOption) (*Service, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

selenium_test.go needs to be updated to test Selenium v4:

selenium3Path = flag.String("selenium3_path", "", "The path to the Selenium 3 server JAR. If empty or the file is not present, Firefox tests using Selenium 3 will not be run.")

t.Run("Selenium3", func(t *testing.T) {

} else {

t.Run("Selenium3", func(t *testing.T) {

SeleniumVersion: semver.MustParse("3.0.0"),

s, err = selenium.NewSeleniumService(webDriverPath, port, c.ServiceOptions...)

We should also add Selenium v4 to be automatically downloaded by vendor/init.go:

url: "https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar",

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