kebomix kebomix - 1 year ago 114
Ruby Question

Capybara::ElementNotFound on all specs only on Travis

I'm using selenium, capybara with rspec for testing, i noticed all tests pass locally, but on travis all tests fail with this error on each spec.


I'm not sure what is wrong here, here is the specs runner on .travis.yml

- xvfb-run bundle exec rspec spec/features/*.rb

for spec_helper.rb here is my config:

RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.use_transactional_fixtures = false
config.infer_base_class_for_anonymous_controllers = false1
config.filter_run_excluding :broken => true

Capybara.default_driver = :selenium
Capybara.default_selector= :css
Capybara.run_server = true
Capybara.default_wait_time = 30

Answer Source

Well I found the reason of the issue and the solution.

Reason: We use responsive design, and apparently travis uses small windows size which turned on the mobile design and that is why it couldn't find the elements.


- xvfb-run --server-args="-screen 0 1024x768x24" bundle exec rspec spec/features/*.rb

You basically set windows size to a larger size.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download