I have a rails 2.3 application running on REE. I am using capybara 1.1.2, cucumber 1.1.0, poltergeist (used both 0.6.0 and lastest from github) and phantomJS 1.5.0. My problem is that I believe I have a race condition in phantomJS that is causing my cucumber tests to randomly fail. The cucumber test work perfectly when I run them in Chrome so I am pretty sure the problem is in poltergeist or phantomJS. When I run the cucumber tests in PhantomJS (so that I can run them on the CI server) I will randomly get errors like this:
One or more errors were raised in the Javascript code on the page:
TypeError: 'undefined' is not a function
http://static.ak.fbcdn.net/rsrc.php/v2/yd/r/c9z-2BUoufJ.js:75
http://static.ak.fbcdn.net/rsrc.php/v2/yd/r/c9z-2BUoufJ.js:75
http://static.ak.fbcdn.net/rsrc.php/v2/yd/r/c9z-2BUoufJ.js:9 in bound:(?) (Capybara::Poltergeist::JavascriptError)
./features/step_definitions/site_steps.rb:8:in `/I am on the home page/'
features/account_creation.feature:89:in `Given I am on the home page'
Failing Scenarios:
cucumber features/account_creation.feature:5 # Scenario: I should be able to start creating a resume without signing up
cucumber features/account_creation.feature:79 # Scenario: I should be able to log in with an old username and password
cucumber features/account_creation.feature:88 # Scenario: I should be able to remember my login so that when the browser is closed I am automatically logged in
Based off of the Github page for poltergeist I have added this to my env.rb to solve the rack pre version 1.3 race condition problems:
Capybara.server do |app, port|
require 'rack/handler/thin'
Thin::Logging.silent = true
Thin::Server.new('0.0.0.0', port, app).start
end
But this has not made any difference that I can tell. Any thoughts would be appreciated even if it is just a suggesting that this is a poltergeist problem or a phantomJS problem so I know how I should ask about it next.
Related
I'm setting up Capybara for the first time and it seems to be calling Chrome instead of Firefox by default.
At first I was getting the webdriver error:
Selenium::WebDriver::Error::WebDriverError:
unable to connect to chromedriver 127.0.0.1:9515*
with associated stacktrace
https://pastebin.com/TW5NWJgu
I was able to clear this by adding a gem 'chromedriver-helper' and the test now opens with chromium.
I also tried adding this to both spec_helper and rails_helper:
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, browser: :firefox)
end
I was able to confirm that rails was able to successfully call firefox because the following command in rails_helper does successfully launch Firefox (but does not take any further action) when I start the test (as per comments, I later removed this command).
RSpec.configure do |config|
driver = Selenium::WebDriver.for :firefox
end
I'm getting the same error on a separate machine and on a different rails app (also didn't have geckodriver set-up on the first pass of Capybara)
My understanding is that Capybara should call Firefox by default. There seems to be a second configuration somewhere that I can't find. Does anyone have an idea of where I might find the line that is calling chrome?
From the log file you provided we can see that you're using Rails 5.1, RSpec 3.8 and Capybara 2.18. Since the log also includes "actionpack-5.1.6/lib/action_dispatch/system_testing/driver.rb" we can tell that you're writing system tests/specs (through rspec-rails). The driver used by system tests is controlled by the driven_by method as documented in the RSpec system spec docs and by default uses the Rails registered :selenium driver which is configured to use Chrome. As documented in the Rails System Test docs you can switch to Firefox by specifying
driven_by :selenium, using: :firefox
Additionally, Capybara 2.18 is pretty much obsolete at this point. You probably want to update to the latest version (3.6 as of now) if you plan on using the latest versions of Firefox/Chrome.
I upgraded my test gems to the following versions:
capybara 2.5.0
capybara-webkit 1.7.1
I installed qt5 and the capybara-webkit gem successfully.
I test my application with cucumber. In a scenario outline that checks some field values, the first example passes but all subsequent examples fail.
After digging into the logs, I found that in every example except the first one, Rails responds with status 304 Not Modified instead of 200 OK which was the previous behaviour.
I monkey patched my application controller for the test environment to respond with headers disabling the cache and all works as expected. But this was just a fix to confirm that page caching was the problem.
Any ideas?
I'm having intermittent build issues on our CI that consistently succeed locally. We had our master build succeed but rebuild fails (without cache clear or any changes). The failures are only on our js-driven feature specs, the others succeed consistently for both CI and dev.
Error: Net::ReadTimeout
Partial Stack:
Rails 4.1.4
RSpec 3.0
Capybara (2.4.1, 2.5, and master)
selenium-webdriver 2.45.0
Failed fix attempts:
Updating capybara and/or selenium
Revert first merge we noticed the errors
Clearing build cache
Updating dev group and/or test group gems
Any help is hugely appreciated!
Ended up solving this one. It's partially due to an error on our part and partially due to a selenium bug.
Steps to reproduce:
visit /path/to/page
alert("whatever") {don't close it}
call visit /path/to/page again
Any subsequent pages selenium loads will still have the alert box open, thus most matchers will break.
I'm getting this error when I run the cucumber tests. Everything seemed to be working fine the previous day but I can't figure out why it stopped working. I was trying to get capybara webkit working and I had changed a couple of files but I don't see why it should affect my tests. Any idea on how to fix this error I'm getting while running the cucumber tests?
Capybara::DriverNotFoundError: no driver called :rack was found, available drivers: :rack_test, :selenium, :webkit, :webkit_debug
You mentioned that you edited many files. Could it be that you didn't revert all the changes you made? I think Capybara would pick the 'rack_test' driver by default, and your system could not find the 'rack' driver.
Since you're doing Cucumber testing, you must have a file called 'env.rb' under the features/support folder. Make sure you don't force 'rack' as your Capybara driver, and your tests should run fine.
I have an application with a bunch of cucumber tests, and I tried using selenium with it today. It took a bit, but I got it running, it starts up selenium, uses the correct database and everything, but everybody has a wrong password.
I can see the user getting created, I can log the password and see that it's the correct password, but every test user just gets redirected back to the login page with the incorrect username/password error.
Is this a Selenium problem, or some other dependent system or am I missing something? It works fine with the standard :rails webrat mode.
I run the task as
rake features
Ubuntu 9.04
machinist 0.3.1
Selenium 1.1.14
Firefox 3.0.10
ruby 1.8.7-p160
cucumber 0.3.7
EDIT: Now, after a restart (office reorg) it won't run tests at all. Firefox just starts, and shuts down, then everything fails.
14:13:25.141 ERROR - Failed to start new browser session, shutdown browser an clear all session data
org.openqa.selenium.server.RemoteCommandException: timed out waiting for window 'null' to appear
I've tried updating the selenium-server.jar from the latest version, and no dice.
Cucumber::Rails.use_transactional_fixtures
Was the culprit. In selenium you can't have transactional fixtures, so writing cucumber steps will be a bit more fun, but whatever. Commenting out the above line fixes the password problem.