I'm trying to get up and running with capybara and I'm testing out the functional differences between poltergeist and selenium-webdriver. A pretty basic test is giving me unexpected results and I'd like to confirm if this is something I'm doing wrong in my configuration, or if this is simply expected behavior.
spec_helper:
require 'capybara/rspec'
# require 'selenium/webdriver'
require 'capybara/poltergeist'
Capybara.run_server = false
# Capybara.default_driver = :selenium
Capybara.default_driver = :poltergeist
Capybara.javascript_driver = :poltergeist
Capybara.app_host = 'http://google.com'
hello_world_spec:
require 'spec_helper'
feature 'testing with rspec' do
before :each do
visit '/'
end
scenario 'visit google main page' do
expect(page).to have_content 'About'
end
scenario 'search for something', js: true do
fill_in 'q', with: 'test search'
# click_on 'Google Search'
sleep 5
page.driver.render 'screenshot.png', full: true
expect(page).to have_content 'Wikipedia'
end
end
The first test succeeds as expected, but the second one only works with selenium. If you perform this test manually in any browser, google will perform the search as you type. With poltergeist, the search is never performed until I manually click the "Google Search" button. What's going on here?