I’m trying to set up DevContainers with a Rails 7.2 app, but I’m having difficulties getting my RSpec system specs to run correctly.
My compose.yaml
file includes the selenium/standalone-chromium
image to run Chrome.
name: "my_app"
services:
rails-app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
volumes:
- ../..:/workspaces:cached
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
depends_on:
- postgres
- selenium
postgres:
image: postgres:16.1
restart: unless-stopped
networks:
- default
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
selenium:
image: selenium/standalone-chromium
restart: unless-stopped
volumes:
postgres-data:
I have updated my Capybara
config as follows:
config.before(:each, type: :system) do
driven_by :selenium, using: :chrome, options
browser: :remote,
url: "http://selenium:4444"
}
end
But I get the following error
Failure/Error: visit(violations_path)
Selenium::WebDriver::Error::WebDriverError:
unable to connect to /home/vscode/.cache/selenium/chromedriver/linux64/128.0.6613.119/chromedriver 127.0.0.1:9515
What am I missing here?
I have tried to find some information online but nothing came out.
- UPDATE –
It looks to me the Selenium server is reachable from the rails app
$ curl --dump-header - http://selenium:4444
HTTP/1.1 302 Found
content-length: 0
Location: /ui/
$ curl -L http://selenium:4444
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<link href="favicon.svg" rel="icon" type="image/svg">
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<link href="logo192.png" rel="apple-touch-icon"/>
<link href="manifest.json" rel="manifest"/>
<title>Selenium Grid</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="index.js"></script>
</body>
</html>
- UPDATE 2
I have updated the Selenium image I use toselenium/standalone-chromium:4.24.0
, the same version of myselenium-webdriver (4.24.0)
, and now I get the same error, but first I get
2024-09-09 08:57:20 ERROR Selenium Exception occurred: Unsuccessful command executed: ["/home/vscode/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.24.0/bin/linux/selenium-manager", "--browser", "chrome", "--language-binding", "ruby", "--output", "json"] - Code 65
{"code"=>65, "message"=>"error decoding response body", "driver_path"=>"", "browser_path"=>""}
I tried to understand what the error meant, but I couldn’t find it.