Skip to content

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

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Prendo93
Copy link

Selenium V3 seems to now be considered legacy (https://www.selenium.dev/documentation/legacy/selenium_3/). This PR adds NewSeleniumServiceV4 which sets up the service using the new format for v4. During my (admittedly limited) testing it seems to work as a drop-in replacement for Selenium V3 implementation.

@ChristianSch
Copy link

Would it be possible to merge this? @minusnine

@@ -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.

@@ -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.

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",

@ChristianSch
Copy link

ChristianSch commented Mar 22, 2022

I'm also not sure that this is correct. The PR uses /wd/hub as the urlPrefix (which is a suffix btw), which doesn't seem to be used by selenium 4:

GET http://localhost:4444/wd/hub
-> 
{
  "value": {
    "error": "unknown command",
    "message": "Unable to find handler for (GET) \u002fwd\u002fhub",
    "stacktrace": ""
  }
}

(same for POST)

@Prendo93 did this actually work for you?

@Prendo93
Copy link
Author

Can confirm this is working for me with https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.1.0/selenium-server-4.1.1.jar

I think the urlPrefix is named thus because there are other routes called, eg: /wd/hub/session etc.

@ChristianSch
Copy link

ChristianSch commented Mar 23, 2022

Hm, ok. Do you specify a prefix? Or do you omit it? Would you mind posting a quick example where it's running for you? Would help tremendously!

Edit: it actually does work! It just doesn't work with the selenium standalone docker images for some reason.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants