João Pereira
2013-Jul-18 10:53 UTC
How to assert the value of an input element with assert_select (Rails 4)
Given this HTML in the view:
<form id="new_merchant_user" method="post">
<fieldset>
<div id=''legend''>
<legend>Recover Pasword</legend>
</div>
<input id="merchant_user_email"
name="merchant_user[email]" type="text" value=""
/>
<input class="btn btn-success" name="commit"
type="submit" value="Send Reset Instructions" />
</fieldset></form>
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
<Send Reset Instructions> expected but was
<>..
Expected 0 to be >= 1.
Basically, selecting nothing.
What am I doing wrong here?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/187fdeda-7452-4719-bcc5-3993159a9bf2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Frederick Cheung
2013-Jul-19 11:18 UTC
Re: How to assert the value of an input element with assert_select (Rails 4)
On Thursday, July 18, 2013 11:53:01 AM UTC+1, João Pereira 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''tlook at attributes. assert_select "form input[type=submit][value=''Send Reset Instructions'']" should do the trick Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c354653e-932f-4eb6-bae3-b006ae394b8d%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
João Pereira
2013-Jul-19 11:43 UTC
Re: How to assert the value of an input element with assert_select (Rails 4)
Will try that. Thanks On Friday, July 19, 2013 1:18:33 PM UTC+2, Frederick Cheung wrote:> > > > On Thursday, July 18, 2013 11:53:01 AM UTC+1, João Pereira 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 >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0e32266f-7afc-4f58-b044-aed31721e821%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.