Accessing DOM elements in a HTML 5, CSS 3 setup26 Mar 2015
So, Capybara will use an implementation of a JS friendly back-end (selenium web-driver, phantomjs, etc). Use the execute script functionality to do achieve this. Example.
Given our element looks something like this.
<div class="toggle-switch"><input id="all_notifications_enabled" type="checkbox" checked="checked"><label for="all_notifications_enabled"></label></div>
The label element is the UI part and the input element contains the action, and yes, the input element is hidden.
where executescript is an extension of selenium-webdriver’s driver.executescript method.