poltergeist
Poltergeist current_url command is returning page_info hash instead of a URL
Problem I have an rspec feature test that is using capybara/poltergeist with :js => true and is doing something really simple: visit borrow_path click_on "Get Started" page.should have_content "Create Your Account" Clicking Get Started takes the user to our sign up page and then poltergeist raises a Timeout Error on the page.should have_content assertion, despite the screenshot of the page confirming that the content is, in fact, on the page. The error is: Failure/Error: page.should have_content "Create Your Account" Capybara::Poltergeist::TimeoutError: Timed out waiting for response to {"name":"find","args":["xpath","/html"]}. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the Poltergeist :timeout option to a higher value will help (see the docs for details). If increasing the timeout does not help, this is probably a bug in Poltergeist - please report it to the issue tracker. # ./spec/features/borrower/signup_spec We've tried upping the timeout to 5 minutes, still the same error. This doesn't happen consistently, every few runs the test will pass. Details With that in mind, I turned :debug on in our setup as follows: Capybara.register_driver :poltergeist do |app| # use 'page.driver.debug' as a js debugger # see https://github.com/jonleighton/poltergeist/tree/v1.5.0#remote-debugging-experimental Capybara::Poltergeist::Driver.new(app, :timeout => 300, :inspector => true, :debug => false, :window_size => [1280, 1400], :js_errors => true) end and re-ran the tests. The failed spec's output looks as follows: {"name"=>"current_url", "args"=>[]} {"response"=>{"page_id"=>126, "ids"=>[0]}} An error occurred in an after hook URI::InvalidURIError: bad URI(is not URI?): {"page_id"=>126, "ids"=>[0]} occurred at /home/rof/.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/uri/common.rb:176:in `split' {"name"=>"current_url", "args"=>[]} {"response"=>"http://127.0.0.1:49891/users/sign_up?m=borrower"} {"name"=>"current_url", "args"=>[]} {"response"=>"http://127.0.0.1:49891/users/sign_up?m=borrower"} {"name"=>"body", "args"=>[]} {"response"=>"http://127.0.0.1:49891/users/sign_up?m=borrower"} I can't find any hints as to why a call to current_url is returning the page_id hash instead of a URL, but this actually breaks all subsequent feature tests and causes find to always return true: {"name"=>"find", "args"=>["xpath","/html"]} {"response"=>"true"} Which causes this exception on all subsequent tests (whether they're tagged :js => true or not): Failure/Error: Unable to find matching line from backtrace NoMethodError: undefined method `[]' for true:TrueClass # /home/rof/cache/bundler/ruby/1.9.1/gems/poltergeist-1.5.0/lib/capybara/poltergeist/browser.rb:54:in `find' # /home/rof/cache/bundler/ruby/1.9.1/gems/poltergeist-1.5.0/lib/capybara/poltergeist/driver.rb:114:in `find' # /home/rof/cache/bundler/ruby/1.9.1/gems/poltergeist-1.5.0/lib/capybara/poltergeist/driver.rb:118:in `find_xpath' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/finders.rb:154:in `block in resolve_query' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/base.rb:77:in `synchronize' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/finders.rb:150:in `resolve_query' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/finders.rb:129:in `all' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/matchers.rb:107:in `block in assert_no_selector' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/base.rb:81:in `synchronize' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/node/matchers.rb:106:in `assert_no_selector' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/session.rb:396:in `block (2 levels) in <class:Session>' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/session.rb:81:in `reset!' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara.rb:253:in `block in reset_sessions!' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara.rb:253:in `each' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara.rb:253:in `reset_sessions!' # /home/rof/cache/bundler/ruby/1.9.1/gems/capybara-2.2.1/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:471:in `instance_eval' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:471:in `instance_eval_with_rescue' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:242:in `instance_eval_with_rescue' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:31:in `run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:85:in `block in run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:85:in `each' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:85:in `run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:446:in `run_hook' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:350:in `run_after_each_hooks' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:298:in `run_after_each' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:120:in `block in run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-rails-2.14.0/lib/rspec/rails/example/controller_example_group.rb:158:in `call' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-rails-2.14.0/lib/rspec/rails/example/controller_example_group.rb:158:in `block (2 levels) in <module:ControllerExampleGroup>' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_exec' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/extensions/instance_eval_with_args.rb:16:in `instance_eval_with_args' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:247:in `instance_eval_with_args' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:106:in `block (2 levels) in run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:104:in `call' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:104:in `run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/hooks.rb:446:in `run_hook' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:340:in `run_around_each_hooks' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:256:in `with_around_each_hooks' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example.rb:111:in `run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:390:in `block in run_examples' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:386:in `map' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:386:in `run_examples' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/example_group.rb:371:in `run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `map' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:28:in `block in run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/reporter.rb:58:in `report' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/command_line.rb:25:in `run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:80:in `run' # /home/rof/cache/bundler/ruby/1.9.1/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun' Any idea what's going on?
Related Links
How can I use “includeJs” function of phantomjs with poltergeist?
Poltergeist ruby gem fails to process `:shift` modifier in `send_keys`
Using Poltergiest to give user of app a screenshot of their page
Poltergeist 1.9.0 w/Ruby 1.9.3
Post via Capybara and Poltergiest for API testing
Poltergeist current_url command is returning page_info hash instead of a URL
How does one test the content of confirm dialogs using poltergeist?
Using Poltergeist, Phantom JS instances are not exiting during every rspec run
Render page element with padding in Poltergeist
Can I monkey patch the phantomjs browser api with execute_script?
send_keys support for Poltergeist?