In my Rails 3 app, I've been using jQuery's attr() method to do things like this:
$('#application_dust_type_id').attr('disabled', 'disabled');
I would use Test/Unit, capybara and capybara-webkit to test this with:
assert page.has_selector? 'select[id=application_dust_type_id][disabled=disabled]'
Now, I'm trying to switch to using the prop method, as jQuery recommends:
$('#application_dust_type_id').prop('disabled', true)
But now the above assertion fails, even though the javascript still works the same in the browser.
How can I make an assertion based on an element's property (instead of an attribute) using capybara?
Try just checking for the existance of a disabled
attribute as that is all that is really required to disable an input:
assert page.has_selector? 'select[id=application_dust_type_id][disabled]'
Note that the value of a disabled
attribute is moot. You could set disabled="false"
or disabled="foobar"
and the element would be rendered as disabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With