Skip to content

[ChromeDriver] Tests failing with invalid session id #468

Description

@PragTob

Howdy fellow wallabyers!

We have some tests that are stubbornly flaky on CI and sometimes locally and I can't for the live of me figure out why that might be happening.

I couldn't reproduce locally right now but on CI a colleague had to rerun the tests 5 times for them to pass.

Error

    1) test langing page contains css (PricingEngineWeb.LandingPageTest)
      apps/pricing_engine_web/test/pricing_engine_web/features/landing_page_test.exs:5
      ** (FunctionClauseError) no function clause matching in Wallaby.Experimental.Selenium.WebdriverClient.cast_as_element/2
      The following arguments were given to Wallaby.Experimental.Selenium.WebdriverClient.cast_as_element/2:

          # 1
          %Wallaby.Session{driver: Wallaby.Experimental.Chrome, id: "444f39bc45a713370fb47558d9e539ac", screenshots: [], server: Wallaby.Experimental.Chrome.Chromedriver, session_url: "http://localhost:47863/session/444f39bc45a713370fb47558d9e539ac", url: "http://localhost:47863/session/444f39bc45a713370fb47558d9e539ac"}

          # 2
          {"message", "invalid session id\n  (Driver info: chromedriver=72.0.3626.121,platform=Linux 4.14.133-88.105.amzn1.x86_64 x86_64)"}

      Attempted function clauses (showing 2 out of 2):

          defp cast_as_element(parent, -%{"ELEMENT" => id}-)
          defp cast_as_element(parent, -%{"element-6066-11e4-a52e-4f735466cecf" => id}-)

      code: |> assert_has(css(".login"))
      stacktrace:
        (wallaby) lib/wallaby/experimental/selenium/webdriver_client.ex:566: Wallaby.Experimental.Selenium.WebdriverClient.cast_as_element/2
        (elixir) lib/enum.ex:1340: anonymous fn/3 in Enum.map/2
        (stdlib) maps.erl:232: :maps.fold_1/3
        (elixir) lib/enum.ex:1964: Enum.map/2
        (wallaby) lib/wallaby/experimental/selenium/webdriver_client.ex:43: Wallaby.Experimental.Selenium.WebdriverClient.find_elements/2
        (wallaby) lib/wallaby/driver/log_checker.ex:6: Wallaby.Driver.LogChecker.check_logs!/2
        (wallaby) lib/wallaby/browser.ex:1140: anonymous fn/3 in Wallaby.Browser.execute_query/2
        (wallaby) lib/wallaby/browser.ex:146: Wallaby.Browser.retry/2
        test/pricing_engine_web/features/landing_page_test.exs:8: (test)
 ..........

Test Code

Multiple tests are randomly failing, one of them being our easiest:

  test "langing page contains css", %{session: session} do
    session
    |> visit("/")
    |> assert_has(css(".login"))
    |> assert_has(css(".login__header"))
    |> assert_has(css(".login__main"))
    |> assert_has(Query.text("Welcome to Pricing Hub"))
    |> assert_has(link("test__google-auth-link"))
  end

The others are usually simple CRUD tests (app isn't that complex yet) :) Often times 2 of them are failing. Sometimes it's just one.

There is no database access here. Just good old landing page. The session is also piped through from beginning to end so no issues with stale sessions.

Environment

  • Wallaby 0.23.0
  • Chromedriver configured to use with chromium, Chromedriver 72 on CI, 76 locally (no idea why it's that old on CI...)
  • Elixir 1.9.0/1.9.1
  • Erlang 22
  • On CI tests are running inside a docker container for testing
  • Tests are being executed in parallel/async

The whole thing reminds me a bit of #221

Any ideas/help/input on how to remedy this would be highly appreciated 👌

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions