How can I check that a form field is prefilled correctly using capybara?

后端 未结 5 1394
不知归路
不知归路 2021-01-30 01:48

I have a field with a proper label that I can fill in with capybara without a problem:

fill_in \'Your name\', with: \'John\'

I\'d like to check

5条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 02:36

    If you specifically want to test for a placeholder, use:

    page.should have_field("some_field_name", placeholder: "Some Placeholder")
    

    or:

    expect(page).to have_field("some_field_name", placeholder: "Some Placeholder")
    

    If you want to test the user-entered value:

    page.should have_field("some_field_name", with: "Some Entered Value")
    

提交回复
热议问题