javascriptcapybaraweb-testingsite-prism

Capybara Set doesn't trigger events after changing the value


Be careful using 'set' rather than the other built-in methods, as it doesn't trigger events after changing the value, as pointed out in a comment here: How to use fill_in with find in Capybara (if possible)

e.g.

find(:css, "input[id$='donation_pledge_hundreds']").set("10")

I am using ruby, capybara, and site-prism. AS I understand it, site-prism is meant to be used by obtaining capybara node elements, and then calling methods on them e.g. click

I need to set the value of a text box, and have therefore tried to call set on the relevant capybara node element. Unfortunately this has not fired off the related javascript.

What should I try to resolve this issue? Should I just use the capybara fill_in method?


Solution

  • I'd go for fill_in since it's the closest way to manual testing which we aim for when writing feature tests. I've found out that when you use set, you won't be able to discover problems like field being overlayed by other element, for instance, therefore you could find out about the field being not clickable only by manual checkup.