我有一个非常基本的测试,有时可以工作,有时会失败,出现不一致的错误消息,例如:
Failure/Error: Unable to find matching line from backtrace
AbstractController::ActionNotFound:
The action 'location_states' could not be found for LocationController
或:
Failure/Error: select 'Nationwide', from: 'location_type'
Capybara::ElementNotFound:
Unable to find option "Nationwide"
或:
Failure/Error: Unable to find matching line from backtrace
RuntimeError:
Circular dependency detected while autoloading constant LocationOptions
调用location_states初始化location_type
下拉框的AJAX回调是在一个Angular范围内,所以我想知道如果这就是为什么有这种不一致的行为。我尝试将Capybara.default_wait_time
增加到10,但这似乎没有改变任何东西。
似乎引起这一切的特定行:
select 'Nationwide', from: 'location_type'
由于Capybara的选择最终依赖于find
,我认为我不会遇到同步问题,但我想我在这里错过了一些东西。
我通过poltergeist使用phantom.js驱动程序。
我在使用rspec、capybara和poltergeist时遇到了类似的问题。Capybara报告它找不到一个在页面上清晰显示的元素。我使用save_and_open_page并验证它是否存在。当然,当我在"page"前加上"sleep 5"语句时。查找(:css, '#element_id')",那么测试通过。