elixir-wallaby / web_driver_client

MIT License
14 stars 13 forks source link

Is /sessions W3C compliant? #24

Open mhanberg opened 4 years ago

mhanberg commented 4 years ago

I was playing around with the repo last night to see if it could run Geckodriver as a standalone server (no selenium), and I was seeing some failing tests when calling FetchSessions.

After some investigations, it looks like that endpoint is not in the webdriver spec. Geckodriver has never implemented the JWP, which would explain why it doesn't implement that endpoint but chromedriver does.

Does that seem correct?

Thanks!

PS: I was wanting to see if geckodriver standalone would be faster than selenium+geckodriver

aaronrenner commented 4 years ago

I remember I noticed that too, but it appears I was able to run FetchSessions across all of the drivers WebDriverClient is currently supporting

https://github.com/aaronrenner/web_driver_client/blob/600722c17057ee3350081e635cf3f93c067bfedd/test/integration/session_mangement_test.exs#L24-L28

If you wanted to run the web_driver_client tests against geckodriver directly you could edit WebDriverClient.IntegrationTesting.Scenarios and add the following:

  1. Add a scenario to @scenarios
    %Scenario{
      driver: :geckodriver,
      browser: :firefox,
      session_configuration_name: :w3c_headless,
      protocol: :w3c
    }
  2. Add a new clause to get_start_session_payload/1
    def get_start_session_payload(%Scenario{
          driver: :geckodriver,
          session_configuration_name: :w3c_headless
        }) do
      %{
        capabilities: %{
          alwaysMatch: %{
            "moz:firefoxOptions" => %{
              "args" => [
                "-headless"
              ]
            }
          }
        }
      }
    end
  3. Add a new clause to get_default_base_url/1

Once these updates are done, you should be able to run the geckodriver tests with

$ mix test --only integration_test_driver:geckodriver

I'm curious what you find out. I think I remember geckodriver was a bit buggy, but that could have been because I was trying to send JWP requests to it. 😉

mhanberg commented 4 years ago

Yes, I did all that, already. That is how I noticed that the calls to FetchSessions were failing.

I wonder if this means that FetchSessions shouldn't be a supported command for w3c servers, since it technically isn't supported.

aaronrenner commented 4 years ago

I think it's still useful for drivers that support it. Especially when when wallaby starts up chromedriver (I believe that returns a w3c response). Out of curiosity, what is the error being returned?

mhanberg commented 4 years ago

Returns a 405 Method Not Allowed.

Seems to return that for any endpoint that doesn't exists.

mhanberg commented 4 years ago

I think geckodriver also only supports one sessions per instance of the server, which might explain why it doesn't implement an endpoint to fetch all sessions.