Reputation: 902
I'm getting this exception and I can't figure out why.
expected not to find xpath "/html/body/*", found 3 matches: "", "Log in Welcome back Sign up Join the community myproj.com Community curated directory of 0 EVENTS", "". Also found "", which matched the selector but not all filters. (Capybara::ExpectationNotMet)
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara/node/matchers.rb:125:in `block in assert_no_selector'
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara/node/base.rb:84:in `synchronize'
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara/node/matchers.rb:121:in `assert_no_selector'
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara/session.rb:686:in `block (2 levels) in <class:Session>'
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara/session.rb:109:in `reset!'
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara.rb:285:in `block in reset_sessions!'
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara.rb:285:in `each'
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara.rb:285:in `reset_sessions!'
~/.rvm/gems/ruby-2.2.4@myproj/gems/capybara-2.6.2/lib/capybara/cucumber.rb:8:in `After'
EDIT:
I'm using selenium-webdriver (firefox 42.0)
Upvotes: 1
Views: 253
Reputation: 11
i had the same issue. what i've done to solve it, it's to add visit 'about:blank' in the last line of the test case.
ie:
it 'testing search functionality...' do
visit '/'
fill_in('search_id', with: 'tablet')
click_link 'Search'
expect(page).to have_content 'tablet'
visit 'about:blank' #<-- this flashes page body (the buffer
# of the last page) and that's it
end
good luck :)
Upvotes: 1
Reputation: 902
The problem in this case was that after I would click a link, the page that the link was pointing to didn't get to load before the expectation was run. I had the click and the expectation in two different steps. So by adding an expectation to the step that did the clicking, I was able to fix this (by forcing capybara to wait for the new page to load).
Upvotes: 0