I want to run an E2E test (simple string return) on a web application created with Rails.
EnvironmentOS: ArchLinux
Rails version: 5.2.3
Ruby version: 2.5.7p206
Docker definition
github repository
The test was executed with the following contents.
spec/support/capybara.rbThe 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 (
app,
browser:: chrome,
url: "http://192.168.0.6:3000/",
options: options
)
end
Capybara.javascript_driver =: chrome_headless
Capybara.run_server = false
Capybara.app_host = nil
spec/features/post_page_spec.rb
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')
end
end
The following command returns an error like this
docker-compose run web bin/rspec
Error message
- Set URL in
Capybara.app_host
->The error did not change. - Set URL in
Capybara.server_host
->The error did not change. - Manual test with Chrome browser->You can get the string HelloWorld as expected.
- `docker-compose run web bin/rspec '
-
Answer # 1
-
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.
Related articles
- ruby - i added a rails column, but i can't associate it with the user table
- ruby - [rails] posts added to favorites are not saved
- ruby on rails - when a photo is added to a folder on the pc, i want to display it on the browser of the web application!
- ruby - the last db setting doesn't work when deploying rails app on aws
- ruby on rails 5 - actioncontroller :: invalidauthenticitytoken cannot be resolved
- ruby on rails - cart function routing error cannot be resolved
- ruby on rails - rails s can't
- ruby on rails - how to transition from the top page
- ruby on rails - i want to implement a function for administrator users to register luggage for general users in rails
- ruby on rails - things associated with a foreign key cannot be called in view
- ruby on rails 6 - environment construction of ruby on rails
- ruby on rails - error in controller when transitioning with rails6 destory action
- ruby - rails tutorial chapter 2 (6th edition)
- ruby on rails - access fails after seed after deploying to heroku
- ruby on rails runtime error cannot be resolved
- ruby on rails - missing required keys: i'm having trouble resolving the [: id] error
- ruby on rails 5 - some items are not saved in db when posting from rails form
- bootstrap display in ruby on rails is broken
- ruby - [rails] i can't install the add favorite button
- ruby on rails - dealing with wrong number of arguments (given 1, expected 2)
- ruby on rails - how to resolve lib/rack/session/abstract/idrb: 375: in'commit_sesion' that occurs in rspec
- ruby on rails - about request spec of rspec about test code at login
- ruby on rails - how to test that a specific element has a class name using rspec/capybara
- ruby - [rails] unable to resolve "name error in affiliates controller # show" error
- ruby on rails - rails rspec argumenterror occurs when the mock under test has arguments
- [ruby + selenium] how to get the number of characters for each individual page
- ruby on rails - i want to set responsestatus to 200, but it becomes 401
- ruby on rails - i want to write a rails tutorial test in rspec
- ruby on rails - phenomenon that the test that should be an "rspec" error passes
- ruby - i can't install ffi with everyday rails setup
Please set the test target URL only with
Capybara.app_host
.Capybara :: Selenium :: Driver
The 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.