eiriksm.dev: Could not open connection: unknown error: cannot find Chrome binary

Author:
Source

I was just recently starting to get this on projects after (at least I think that’s why) I updated to Chrome 120.

      Could not open connection: unknown error: cannot find Chrome binary
        (Driver info: chromedriver=120.0.6099.71 (9729082fe6174c0a371fc66501f5efc5d69d3d2b-refs/branch-heads/6099_56@{#13}),platform=Linux 6.2.0-37-generic x86_64) (BehatMinkExceptionDriverException)

That’s the error message in behat at least, which I think originates from the actual webdriver (chromedriver) response. If I look at the debug information from the chromedriver logs it says this:

[1703837483,910][INFO]: [0ca18bb59db30d5acd358de02a01da0a] RESPONSE InitSession ERROR unknown error: cannot find Chrome binary

Well the error is clear enough. It can not find the binary. That’s fine by me, but where would I go about informing about the binary? Well, for me that would be in behat.yml:

@@ -33,8 +33,9 @@ default:
               w3c: false
           marionette: null
           chrome:
+            binary: /usr/bin/google-chrome
             switches:

This probably translates to something like this, while initiating the session with chromedriver (slightly edited for relevance and brevity):

[1703887172,675][INFO]: [95b2908582293fa560a7301661f5e741] COMMAND InitSession {
   "desiredCapabilities": {
      "chrome.binary": "/usr/bin/google-chrome",
      "chrome.extensions": [  ],
      "chrome.switches": [ "--ignore-certificate-errors", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage" ],
      "goog:chromeOptions": {
         "args": [ "--ignore-certificate-errors", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage" ],
         "binary": "/usr/bin/google-chrome",
         "extensions": [  ]
      },
      "ignoreZoomSetting": false,
      "marionette": true,
   }
}

If you are using some other tool that interacts with chromedriver, I am sure you are already setting some parameters there, which you could append this new parameter to.

Read more