I been using :firefox drivers for capyabara and this test was passing but when I switch to poltergeist driver the test been failing now with the following error:
Minitest::UnexpectedError: Capybara::ElementNotFound: Unable to find field "email"
Here is the capybara and poltergeist setup:
def setup
# FactoryGirl.lint
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.start
Capybara.run_server = true
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :js_errors => false)
end
Capybara.default_driver = :poltergeist
Capybara.current_driver = :poltergeist
Capybara.javascript_driver = :poltergeist
Capybara.app_host = 'http://localhost:4200'
Capybara.server_port = 3000
Capybara.default_max_wait_time = 5
end
Here is the test:
test "User should be able to signin" do
visit '/'
wait_for_ajax
fill_in 'email', with: @user.email
fill_in 'password', with: @user.password
assert true
end
So, when I changed the driver to :selenium the test pass with no error.
How do I setup/fix poltergeist to pass this test?
I took screenshot and it shows loading indicator which is a div that is removed in afterModel Ember hook using the following code:
_ember['default'].$('.ember-load-indicator').remove();
For Ajax calls we have the following function as test helper to wait for ajax calls:
def wait_for_ajax
Timeout.timeout(Capybara.default_wait_time) do
loop until finished_all_ajax_requests?
end
end
def finished_all_ajax_requests?
page.evaluate_script('jQuery.active').zero?
end