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

Headless Chrome sessions not starting on recent Chrome versions #257

Open
michallepicki opened this issue Feb 7, 2024 · 5 comments
Open

Comments

@michallepicki
Copy link

To fix the “invalid session id” we need to call:

Hound.start_session([additional_capabilities: %{browserName: "chrome"}])
@ScreenverseJames
Copy link

Thank you, Michał, for posting this. We hit the same issue, and your workaround worked nicely for us! Very much appreciated!

@agatheblues
Copy link

Worked for us too! Thanks a bunch ❤️

@HarshBalyan
Copy link

HarshBalyan commented Mar 11, 2024

@michallepicki How did you conclude that?
I tried your suggestion but it didn't work.
Before I see this invalid session ID error, i see the following response for a POST /session call to the driver server.

%{
   "sessionId" => "e9796a5997cef178db3120e89d0f1f28",
   "status" => 33,
   "value" => %{
     "message" => "session not created: Chrome failed to start: exited normally.\n  (session not created: DevToolsActivePort file doesn't exist)\n  (The process started from chrome location /usr/lib/chromium/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)\n  (Driver info: chromedriver=121.0.6167.184 (057a8ae7deb3374d0f1b04b36304d236f0136188-refs/branch-heads/6167@{#1818}),platform=Linux 5.15.49-linuxkit-pr aarch64)"
   }
 }

Any idea?

@michallepicki
Copy link
Author

How did you conclude that?

I inspected responses from chromedriver somewhere in hound code, and there was an error about incorrect browser name. Unfortunately I am not familiar with the problem you're facing

@HarshBalyan
Copy link

HarshBalyan commented Mar 12, 2024

I finally solved it by overriding the chromeOptions that are set by default_capabilities for chrome_headless browser(I don't set user_agent in additional capabilities). I had to also set the browserName as an additional capability.
My config

config :hound,
  driver: "chrome_driver",
  browser: "chrome_headless",
  host: System.get_env("HEADLESS_BROWSER_URL"),
  port: 9515

I started my hound_session/1 in test like

defmodule SomeTest do
  use ExUnit.Case
  use Hound.Helpers

  hound_session(additional_capabilities())

  # some tests
  
  defp additional_capabilities do
      [
        additional_capabilities: %{
          :"goog:chromeOptions" => %{
            "args" => [
              "--headless",
              "--disable-gpu",
              "--no-sandbox",
              "--disable-dev-shm-usage",
              "--disable-software-rasterizer"
            ]
          },
          browserName: "chrome"
        }
      ]
  end
end

I am using a flavour of this docker image for starting a chrome driver server.

backspace added a commit to backspace/adventures that referenced this issue Apr 16, 2024
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

4 participants