1

I am proceeding to integration testing and I have to populate some hidden field. The problem is this seem not to be taken into account

it "submits project form" do
    page.all("#project_description", :visible => false).set(@project.description)
    click_button  "submit"
    expect(page).to have_content @project.description
end

the problem is that I get this error message when launching the task Description can't be blank. I am sure the the hidden field is found, but the filling is not done. How can I fix it ? (I set Capybara.ignore_hidden_elements to false)

DGM
  • 26,629
  • 7
  • 58
  • 79
user1611830
  • 4,749
  • 10
  • 52
  • 89
  • Duplicate of https://stackoverflow.com/questions/10804897/how-to-fill-hidden-field-with-capybara – Jared Aug 31 '16 at 02:14

1 Answers1

2

It may not be the best solution, but you could do it with javascript. For exemple, if you're using jQuery:

page.execute_script "$('#project_description').val('#{@project.description}')"

If there are some ' characters in the @project.description, you need to escape them (see JavaScriptHelper, not sure how to use it in integration test).

Baldrick
  • 23,882
  • 6
  • 74
  • 79