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

Issues with new selenium versions #793

Open
1 task done
revati opened this issue Dec 23, 2024 · 0 comments
Open
1 task done

Issues with new selenium versions #793

revati opened this issue Dec 23, 2024 · 0 comments

Comments

@revati
Copy link

revati commented Dec 23, 2024

Elixir and Erlang/OTP versions

% elixir -v
Erlang/OTP 27 [erts-15.1.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.18.0 (compiled with Erlang/OTP 27)

Operating system

MacOS 13.1

Browser

selenium

Driver

selenium

Correct Configuration

  • I confirm that I have Wallaby configured correctly.

Current behavior

im using selenium docker image: selenium/standalone-chromium (4.27.0 grid version, 131 chrome version) (there is no working chrome standalone docker for m1 mac).

Image starts up and i can access selenium grid ui, i can use curl to create session:

% curl -X POST http://localhost:4444/wd/hub/session \
  -H "Content-Type: application/json" \
  -d '{
    "capabilities": {
      "alwaysMatch": {
        "browserName": "chrome",
        "goog:chromeOptions": {
          "args": ["--headless", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage"]
        }
      }
    }
  }'

i have wallaby configured:

config :wallaby,
  otp_app: :my_app,
  driver: Wallaby.Selenium,
  selenium: [
    capabilities: %{
      "goog:chromeOptions": %{
        args: ["--headless", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage"]
      },
      browserName: "chrome"
    }
  ]

Wallaby.start_session() returns (RuntimeError) Could not start a new session. No nodes support the capabilities in the request

#782 it turns out 4.8.3 version should be used (last published docker image 2 years ago without m1 arm support).

Debugging internally, i noticed, that wallaby wraps capabilities config into desiredCapabilities that is no longer working for newer versions of selenium.

# lib/wallaby/webdriver_client.ex:24 
-    params = %{desiredCapabilities: capabilities}
+    params = %{capabilities: capabilities}

# lib/wallaby/selenium.ex
-      id = response["sessionId"]
+      id = get_in(response, ["value", "sessionId"])

Capabilities has different payload structure (note payload is wrapped in alwaysMatch):

config :wallaby,
  otp_app: :my_app,
  driver: Wallaby.Selenium,
  selenium: [
    capabilities: %{
      alwaysMatch: %{
        "goog:chromeOptions": %{
          args: ["--headless", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage"]
        },
        browserName: "chrome"
      }
    }
  ]

With those changes fallowing code gets executed properly:

defmodule Knabis.Source.Fetcher do
  alias Wallaby.{Browser, Session}

  def fetch(url) do
    {:ok, session} =
      Wallaby.start_session()

    session
    |> Browser.visit(url)
    |> Browser.text()
    |> finalize_session(session)
  end

  defp finalize_session(result, session) do
    Wallaby.end_session(session)
    result
  end
end

Expected behavior

To work with never selenium.

I understand there might be more update work/testing needed to fully support newer selenium endpoints, so i don't expect this to be implemented right away.

Bottom line: other people should not spend few days debugging it, please add those caveats in documentation, that legacy version of selenium only is supported.

Test Code & HTML

Im not sure what to put here.

Demonstration Project

No response

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

No branches or pull requests

1 participant