Capybara :: ElementNotFound仅在Travis的所有规格上 [英] Capybara::ElementNotFound on all specs only on Travis
问题描述
我正在使用带有rspec的硒,水豚进行测试,我注意到所有测试均在本地通过,但在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.
Capybara::ElementNotFound:
我不确定是什么这里是错误的,这是.travis.yml上的规范运行程序。
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
对于spec_helper.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
推荐答案
我找到了问题的原因和解决方案。
Well I found the reason of the issue and the solution.
原因:我们使用自适应设计,而travis显然使用了很小的窗口尺寸,从而开启了移动设计,这就是为什么它不能找不到元素。
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.
解决方案:
script:
- xvfb-run --server-args="-screen 0 1024x768x24" bundle exec rspec spec/features/*.rb
您基本上将窗口大小设置为更大的大小。
You basically set windows size to a larger size.
这篇关于Capybara :: ElementNotFound仅在Travis的所有规格上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!