Capybara 1.1.4 -> 2.1.0 upgrade causes Poltergeist "ObsoleteNode" errors

capybara, phantomjs, poltergeist, rspec

Solution

The other answer didn't work for me. I used select_option

page.find(:css, "#province").find("option[value='Adana']").select_option

Problem

I have a working Capybara 1.1.4 test suite running Poltergeist 1.0.2, running atop PhantomJS 1.9.2 Today I've tried to upgrade Capybara to 2.1.0 & Poltergeist to 1.4.1. Most tests work, but a bunch of page.find() elements on js-enabled tests are returning the folllowing error upon .click: Capybara::Poltergeist::ObsoleteNode: The element you are trying to interact with is either not part of the DOM, or is not currently visible on the page (perhaps display: none is set). It's possible the element has been replaced by another element and you meant to interact with the new element. If so you need to do a new 'find' in order to get a reference to the new element. The strange thing is: - page.find('#my-element') finds the element just fine - page.find('#my-element').value returns the correct value BUT - page.find('#my-element').click returns the above 'ObsoleteNode' error. Has anyone seen this before? I've spent a few hours going through every crazy theory I can think of, and nothing will get elements to click. (Side-note: "#my-element" is just an example. There are many different elements with many different IDs which are failing to .click) Any ideas appreciated.

Original source