ruby - Javascript trigger when using poltergiest/capybara outside of rails -
i'm using capybara, rspec , poltergeist, outside of rails, run headless integrations tests. scenario that, there 2 select fields. if select value in first select field, 2nd select field populated based on value of first select field. if run spec using poltergeist in mac osx, spec works. in ubuntu, fails, seems 2nd select field not populated. have js: true on specs.
here's spec_helper.rb:
require 'capybara/poltergeist' require 'capybara' require 'capybara/rspec' require 'pry' require 'support/session_helper' rspec.configure |config| config.include capybara::dsl config.include capybara::poltergeist config.include sessionhelper capybara.run_server = false capybara.default_driver = :poltergeist capybara.javascript_driver = :poltergeist capybara.app_host = "http://vps-staging.dropmysite.com" options = { js_errors: false } capybara.register_driver :poltergeist |app| capybara::poltergeist::driver.new(app, options) end config.expect_with :rspec |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec |mocks| mocks.verify_partial_doubles = true end end edit adding failing spec
require 'spec_helper' feature 'vps-staging', js: true background visit '/' end let(:timestamp) { time.now.strftime('%y-%m-%d_%h-%m-%s') } feature 'create private server' background sign_in 'blahblah@blahblah.com' end 'successfully creates server' find(:xpath, "//a[@href='/en/private_servers/new']").click directory_field = all(".tagit-new")[0].find("input") select 'ubuntu', from: 'distribution' select '15.04', from: 'version' fill_in 'private_server_profile_name', with: "auto test #{timestamp}" directory_field.set "/home" click_button 'save' visit '/en/dashboard' expect(page.text).to have_content "auto test #{timestamp}" end end end edit thing found out that, bug happens on phantomjs version 1.9.8 , below. 2.0 works fine.
as tom walpole pointed out, updating poltergeist 1.6.0 1.7.0 fixed of problem still need tweak bit solve problem. did create js file hold polyfill , edit spec_helper.rb , tell poltergeist use options, extensions , include polyfill.js changing code from
options = { js_errors: false } capybara.register_driver :poltergeist |app| capybara::poltergeist::driver.new(app, options) end to
options = { js_errors: false, extensions: ["spec/support/polyfill.js"] } capybara.register_driver :poltergeist |app| capybara::poltergeist::driver.new(app, options) end
Comments
Post a Comment