I use Trix Editor to have WISIWIG in my form. I want to test with RSpec and Capybara but trix-editor put the field hidden.
<div class="form-group">
<trix-editor class="formatted_content form-control" placeholder="Description" input="annonce_ad_body_trix_input_annonce_ad"></trix-editor><input type="hidden" name="annonce_ad[body]" id="annonce_ad_body_trix_input_annonce_ad" />
</div>
I need to know how i can fill this hidden field with Capybara to make my test pass. I have try these attemp:
fill_in "annonce_ad[body]", with: "my value"
find(:css, 'trix-editor').set("New text")
find("trix-editor", visible: false).set("my value")
find(:xpath, "//input[@id='annonce_ad_body_trix_input_annonce_ad']", visible: false).set "my value"
find(:xpath, "//*[@id='annonce_ad_body_trix_input_annonce_ad']", visible: false).set("value")
first('input#annonce_ad_body_trix_input_annonce_ad.class', visible: false).set("your value")
None of these have work for me. Someone have any idea how i can fill my body(with trix) in this case?
set
method fills in its text one character at a time (at least with Selenium webdrivers) which makes your test take considerable slower, depending on the length of the string. I ran into this when testing a maxlength of underlying field with 130k characters. Only viable option for me was to fall back to custom JS to create a tmp textarea, and copy&paste the text from there..send_keys([:control, 'a'])
thenc
thenv
is your (hacky) friend here :) – Lophophore