...have a program running in a hidden X screen (like with Xvfb for Selenium tests) you may want to look at that hidden screen occasionally. First, find out what X...
...site using the Page Object Model pattern, for use with Capybara in automated acceptance testing. The Page Object Model is a test automation pattern that aims to create an abstraction...
...of your site's user interface that can be used in tests. The most common way to do this is to model each page as a class, and to then...
...XrayWrapper [object HTMLInputElement]] (Selenium::WebDriver::Error::MoveTargetOutOfBoundsError) I had the Terminal window running the test on my secondary screen, whereas the Selenium-webdriven Firefox always started on my primary one...
...Now if I had focused the secondary screen when running the tests, Selenium could not start Firefox and switch to it (probably because the screens are split), generating the above...
I got this error when running Rails 2.3 tests for Rails LTS. More stacktrace: NoMethodError: undefined method `cache' for Gem:Module /vagrant/rails-2-3-lts-repository/railties/lib/rails_generator/lookup.rb:212:in `each' /vagrant/rails-2-3-lts-repository/railties/lib/rails_generator/lookup.rb:146:in `to_a...
...fix" this in multiple ways: Update your drivers on your machine with RAILS_ENV=test rake webdrivers:chromedriver:update Ignore the driver update-URL in your VCR configuration
Cucumber will clean up files you've uploaded in your Cucumber features automatically with the attached code. Put the file...
...are probably using closures to hide local state, e.g. to have private methods. In tests you may find it necessary to inspect a variable that is hidden behind a closure...
...option is available, not that it is selected. There is a separate step to test that an option is selected. Capybara (0.4.1 or higher) Then /^"([^"]*)" should( not)? be an option...
...you don't need to check the input of hidden fields in an integration test. But e.g. waiting for a datepicker library to write the expected value to this field...
...before continuing the test, which prevents flaky tests, is a valid use case...
...rails generators) with rails g -h. generator model migration controller entry in routes.rb views tests scaffold ✔ ✔ ✔ ✔ ✔ ✔ resource ✔ ✔ ✔ ✔ ✔ model ✔ ✔ ✔ controller ✔ ✔ ✔ migration ✔ Also see this blog post...
end Note that you need to tag the scenario with @allow-rescue to test that an error is shown like this @allow-rescue Scenario: Accessing the admin area requires...
...you use that "db count" and process the loaded elements. A common example is tests: Imagine a test that sets up a few records and finishes the test setup by...
...records have loaded (i.e. cached) their associations too early and now are missing elements. Tests relying on the setup will fail, because they will operate on the loaded records. You...
...as pending, include a failing spec body or RSpec 3 will consider the pending test as failing. The reasoning is: If the spec is flagged as pending but passes, it...
...Specs with --backtrace option Run Cucumber features (with Geordi's --debug option) When all tests are green, look through your Gemfile and remove as many version constraints as possible.
Update rspec to '< 2' Lock haml to '= 3.1.7' Unlock andand Unlock rake Lock test-unit to '= 1.2.3' Lock database_cleaner to '< 1.3' Lock cucumber to '< 2'
...work the way you how you would like it to. To create a nice test coverage report, copy the attached file to lib/tasks/rcov.rake. After that rake rcov:all will run...
...app/controllers/shared and app/models/shared (which may or may not be entirely correct for your case). Tested that it works with Selenium features Doesn't add rake tasks outside development environment
...should way of writing specs for expecting things to happen. However, if you have tests you cannot change (e.g. because they are inside a gem, spanning multiple versions of Rails...
...Solution: Add gem 'minitest' to your Gemfile, before any rspec gem. Another MiniTest::Unit::TestCase is now Minitest::Test. From /Users/makandra/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/test/unit/testcase.rb:8:in ` ' In order to remove this message, you...
...problem of pending AJAX requests dying in the browser when the server ends a test or switches scenarios. We were able to work around this issue in most projects by...
...Listening on localhost:36309, CTRL+C to stop If you are running parallel tests with thin, this will clutter you output. Disable thin logging with these lines: # e.g. in features/support/thin.rb...
Thin::Logging.silent = true Note that this disables all logging in tests. Instead, you also might set a different logger with Thin::Logging.logger = . See Thin::Logging for details...
...gem will show a default of 30 records per page. If you want to test pagination in a Cucumber feature, you don't want to create 31 records just for...
There is a kind of features in web applications that hinder automated integration tests. Examples include cookie consent banners or form captchas. Clearly, these should be disabled so you do...
...not have to explicitly deal with them in each and every test (like, every test starting with accepting the cookies notice). On the other hand, they must be tested as...
...Using Capybara RSpec matchers One rule of thumb I try to follow in capybara tests is using capybara matchers and not plain rspec matchers. One example: visit(some_page)
...sure the datepicker is loaded before interacting with it See also Fixing flaky E2E tests
...above commands does, see explainshell. Note that we use geordi cucumber to run our tests. If you don't, xargs cucumber or similar might work for you. Part of Geordi...
Note that if you plan to freeze your Firefox versions because your Selenium tests break whenever Firefox updates, there is a better way that lets you keep an up-to...