Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capybara::Cuprite::BrowserError: "Cannot find context with specified id" #42

Closed
vizcay opened this issue Jan 28, 2019 · 6 comments
Closed

Comments

@vizcay
Copy link

vizcay commented Jan 28, 2019

I have another set of tests that is failing always with the same structure, for example:

      scenario 'generates report filtered by client name match' do
        visit business_payment_report_path(test_business)
        fill_in 'since date', with: input_date('01/01/2017')
        fill_in 'to date', with: input_date('10/01/2017')
        click_on 'Filter client'
        fill_in 'name', with: 'Smith'
        click_on 'Confirm'
        click_on 'Generate'
        #save_and_open_page or sleep 1
        expect(page).to have_content "Client: 2 - John Smith"
      end

When starting to debug, first I tried to watch in which state was the page with save_and_open_page and to my suprise the test started passing (the same with sleep 1). Now the strange thing it that the report generation inside the spec is not that slow actually.

Anyway I've tried:

expect(page).to have_content "Client: 2 - John Smith", wait: 10

And is raising the same exception, so I think this is not a case where the expectation is timing-out at all.

     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/client.rb:43:in `wait'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/page.rb:185:in `command'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/runtime.rb:159:in `cyclic?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/runtime.rb:147:in `reduce_props'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/runtime.rb:128:in `handle'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser/runtime.rb:33:in `evaluate'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser.rb:237:in `find_all'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/browser.rb:72:in `find'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/driver.rb:68:in `find'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/bundler/gems/cuprite-00d3b2874066/lib/capybara/cuprite/driver.rb:72:in `find_xpath'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:108:in `find_xpath'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/selector_query.rb:149:in `block in resolve_for'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:81:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/selector_query.rb:145:in `resolve_for'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/finders.rb:304:in `block in synced_resolve'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:81:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/finders.rb:302:in `synced_resolve'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/finders.rb:37:in `find'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/document.rb:24:in `text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/text_query.rb:94:in `text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/queries/text_query.rb:25:in `resolve_for'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:707:in `block in _verify_text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/base.rb:85:in `synchronize'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:706:in `_verify_text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/node/matchers.rb:615:in `assert_text'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/session.rb:808:in `block (2 levels) in <class:Session>'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:153:in `block in matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:27:in `wrap_matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/capybara-2.18.0/lib/capybara/rspec/matchers.rb:153:in `matches?'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:50:in `block in handle_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:27:in `with_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/handler.rb:48:in `handle_matcher'
     # /Users/pablo/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/rspec-expectations-3.4.0/lib/rspec/expectations/expectation_target.rb:54:in `to'

Any ideas?

@route
Copy link
Member

route commented Jan 29, 2019

Could you please turn CUPRITE_DEBUG=true on and catch it failing?

@vizcay
Copy link
Author

vizcay commented Jan 29, 2019

Sure!
cuprite_debug.zip

@route
Copy link
Member

route commented Jan 29, 2019

@vizcay from the log I can see that there's a delay between clicking the last button and form submission so that in between we get the node with object_id which is invalid after submitting form as there's not such context and node anymore. That's intermittent issue, your test is running faster than action happens on the page. I'll try to reproduce this behavior with simple test.

@route
Copy link
Member

route commented Jan 31, 2019

I added some fixes to avoid intermittent issues. Feel free to reopen if you still have them

@route route closed this as completed Jan 31, 2019
@vizcay
Copy link
Author

vizcay commented Feb 2, 2019

@route sorry for the delay cannot test it, my full suite is broken because of #47.

@senid231
Copy link

looks like issue similar to #61
please take a look at #61 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants