6

I'm trying to fill in an ActionText rich_text field form input, but can't figure out how to select it. I'm using Rails 6 and ActionText.

With

class Activity
    has_rich_text :description
end

and _form.rb

= f.label :description
= f.rich_text_area :description, class: 'form-control'

Test using:

fill_in "Description", with: "Some description.."

I'll get the error

Capybara::ElementNotFound: Unable to find field "Description" that is not disabled

I suspect the problem is with how the Trix editor dynamically fills in this field as you type. I'm just not sure how to do the input, replicating how the user would be entering text.

Carson Cole
  • 4,183
  • 6
  • 25
  • 35

2 Answers2

4

You can do so by find the trix editor and entering your details manually:

find(".trix-content").set("New value")
Dharman
  • 30,962
  • 25
  • 85
  • 135
thomasstephn
  • 3,775
  • 4
  • 24
  • 29
2

Since Rails 6.1, you can use the fill_in_rich_text_area system test helper. Added in b2b6341374.

Anson
  • 6,575
  • 2
  • 39
  • 33