Add set_hidden_field and submit_form methods ND/BH

This commit is contained in:
Bryan Helmkamp 2008-11-17 14:21:16 -05:00
parent 3abaa924cc
commit 5ee4357cd6
3 changed files with 16 additions and 0 deletions

View File

@ -74,6 +74,10 @@ module Webrat
labels.detect { |label| label.matches_text?(label_text) }
end
def matches_id?(id)
@element["id"] == id.to_s
end
protected
def fields_by_type(field_types)

View File

@ -44,6 +44,11 @@ module Webrat
alias_method :fills_in, :fill_in
def set_hidden_field(field_locator, options = {})
field = locate_field(field_locator, HiddenField)
field.set(options[:to])
end
# Verifies that an input checkbox exists on the current page and marks it
# as checked, so that the value will be submitted with the form.
#
@ -256,6 +261,11 @@ module Webrat
alias_method :clicks_button, :click_button
def submit_form(id)
form = forms.detect { |f| f.matches_id?(id) }
form.submit
end
def dom # :nodoc:
return @dom if @dom

View File

@ -180,6 +180,8 @@ module Webrat
end
def_delegators :current_scope, :fill_in, :fills_in
def_delegators :current_scope, :set_hidden_field
def_delegators :current_scope, :submit_form
def_delegators :current_scope, :check, :checks
def_delegators :current_scope, :uncheck, :unchecks
def_delegators :current_scope, :choose, :chooses