Capybara::ElementNotFound on all specs only on Travis

浪尽此生 提交于 2020-01-15 08:15:35

问题


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.

Capybara::ElementNotFound:

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

script:
- 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
  config.render_views

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

回答1:


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

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

Solution:

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

You basically set windows size to a larger size.



来源:https://stackoverflow.com/questions/20713471/capybaraelementnotfound-on-all-specs-only-on-travis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!