How to assert the value of an input element with assert_select (Rails 4)

Given this HTML in the view:

Recover Pasword

How do I select the value of the button with assert_select? I try

assert_select ‘form input[type=submit]’, “Send Reset Instructions”

but its failing with

expected but was
<>…
Expected 0 to be >= 1.

Basically, selecting nothing.

What am I doing wrong here?

On Thursday, July 18, 2013 11:53:01 AM UTC+1, Joo P. wrote:

Given this HTML in the view:

How do I select the value of the button with assert_select? I try

assert_select ‘form input[type=submit]’, “Send Reset Instructions”

This checks whether the input element contains that text, which doesn’t
look at attributes.

assert_select “form input[type=submit][value=‘Send Reset Instructions’]”

should do the trick

Fred

1 Like

Will try that. Thanks