2013-12-20 40 views
2

我使用硒,水豚與rspec進行測試,我注意到所有的測試通過本地,但在特拉維斯所有測試失敗,每個規格上的這個錯誤。只有在特拉維斯所有規格水豚:: ElementNotFound

Capybara::ElementNotFound: 

我不知道什麼是錯在這裏,這裏是規格上的亞軍.travis.yml

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

爲spec_helper.rb這裏是我的配置:

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 

回答

5

那麼我找到了問題的原因和解決方案。

原因:我們使用響應式設計,顯然Travis使用小窗口尺寸打開移動設計,這就是爲什麼它找不到元素。

解決方案

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

你基本上設置窗口的大小,以更大的尺寸。