Reputation: 11
Recently, I've come across a radio button that seems to be so deeply nested that Capybara simply cannot interact with it.
<div …>
<div …>
<div …>
<ul …>
<li …>
<label …>
<div …>
<input id=”radio1” name=”Section1.Radio1” type=”radio”></input>
<label …> </label>
</div>
</label>
</li>
</ul>
</div>
</div>
</div>
There are about 10 more levels of depth beyond this that I've omitted before hitting the tag.
I’ve tried a combination of capybara’s finders including: choose, click_on, find, find_first; all with various xpath and css combinations. These all result in a generic error “Element not found”. The xpaths and css I use are tested in Chrome and FF developer tools with no issues. The only break I’ve gotten is with the ‘all’ finder.
all(:css, #id_name).first
This seems to result in a found object, when I add ‘click’:
all(:css, #id_name).first.click
I receive an error in Capybara 'undefined method `click' for nil:NilClass (NoMethodError)'
Maybe I should go in a different direction. Anyone have any ideas?
Upvotes: 1
Views: 224