I want to run an E2E test (simple string return) on a web application created with Rails.


OS: ArchLinux
Rails version: 5.2.3
Ruby version: 2.5.7p206
Docker definition
github repository

Current status

The test was executed with the following contents.


The following are Capybara settings

Capybara.register_driver: chrome_headless do | app |
  options = :: Selenium :: WebDriver :: Chrome :: Options.new
  options.add_argument ('-headless')
  options.add_argument ('-no-sandbox')
  options.add_argument ('-disable-dev-shm-usage')
  options.add_argument ('-window-size = 1400,1400')
  options.add_argument ("start-maximized")
  options.add_argument ("disable-infobars")
  options.add_argument ("-disable-extensions")
  options.add_argument ("-disable-gpu")
  Capybara :: Selenium :: Driver.new (
    browser:: chrome,
    url: "",
    options: options
Capybara.javascript_driver =: chrome_headless
Capybara.run_server = false
Capybara.app_host = nil

The following is the test definition

require 'rails_helper'
describe 'Postpage', js: true do
  specify 'DisplayGreeting' do
    visit root_path
    expect (page) .to have_css ('p', text: 'HelloWorld')

The following command returns an error like this
docker-compose run web bin/rspec

Error message

  1. Set URL inCapybara.app_host->The error did not change.
  2. Set URL inCapybara.server_host->The error did not change.
  3. Manual test with Chrome browser->You can get the string HelloWorld as expected.
  4. `docker-compose run web bin/rspec '
  • Answer # 1

    Please set the test target URL only withCapybara.app_host.

    Capybara :: Selenium :: DriverThe URL specified when creating is not the URL to be tested, but the Selenium WebDriver relay server.

    The POST/session request that should not have been specified in the test runs
    This is due to 8.1 New Session which is the Selenium WebDriver specification.

  • Answer # 2

    In spine reflexes from error messages
    I went to the page where access management is being done, and was redirected to the login relationship from there.
    That's it.
    So I went to see if I was going to see the same place as the browser and test.
    As a result, the same place. And I do n’t know! ! !

    Let's test with controllers before features to check the behavior.