Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to replace text in input field with Capybara

Tags:

capybara

For my integration test of editing a record, I try to replace the existing text in a form input field with a new text:

find("input[@id='course_title']").set("a safer workplace")

However,everytime I check the page with

save_and_open_page

the text in the input field is not replaced with the new test.

how can I replace the text value of an input field a new text value in Capybara?

Thanks for your help,

Anthony

like image 549
Toontje Avatar asked Oct 28 '13 14:10

Toontje


1 Answers

There are several ways to do this, try one of these:

fill_in('course_title', :with => 'a safer workplace')
find("input#course_title]").set("a safer workplace")
find(:xpath, "//input[@id='course_title']").set("a safer workplace")
like image 153
Arctodus Avatar answered Nov 05 '22 06:11

Arctodus