Fixed Webrat not finding <button type='submit'>
This commit is contained in:
parent
cdafd2ec0f
commit
44745f6891
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
.DS_Store
|
||||
pkg
|
||||
doc
|
||||
ri
|
||||
email.txt
|
||||
email.txt
|
||||
|
@ -3,7 +3,7 @@ module Webrat
|
||||
|
||||
def self.class_for_element(element)
|
||||
if element.name == "input"
|
||||
if %w[submit image].include?(element["type"])
|
||||
if %w[submit image button].include?(element["type"])
|
||||
field_class = "button"
|
||||
else
|
||||
field_class = element["type"] || "text" #default type; 'type' attribute is not mandatory
|
||||
@ -11,7 +11,6 @@ module Webrat
|
||||
else
|
||||
field_class = element.name
|
||||
end
|
||||
|
||||
Webrat.const_get("#{field_class.capitalize}Field")
|
||||
#rescue NameError
|
||||
# raise "Invalid field element: #{element.inspect}"
|
||||
|
@ -45,7 +45,7 @@ module Webrat
|
||||
|
||||
@fields = []
|
||||
|
||||
(@element / "input, textarea, select").each do |field_element|
|
||||
(@element / "input, textarea, select, button").each do |field_element|
|
||||
@fields << Field.class_for_element(field_element).new(self, field_element)
|
||||
end
|
||||
|
||||
|
@ -77,6 +77,23 @@ class ClicksButtonTest < Test::Unit::TestCase
|
||||
@session.clicks_button
|
||||
end
|
||||
|
||||
#<button type='submit'> is also valid HTML.
|
||||
def test_should_work_with_button_submit
|
||||
@response.stubs(:body).returns(<<-EOS)
|
||||
<form action="/form1" method="post"><p><label for="login">Login</label><br/>
|
||||
|
||||
<input type="text" class="text" name="login"/></p>
|
||||
|
||||
<p><label for="password">Password</label><br/>
|
||||
<input type="password" class="password" name="password"/></p>
|
||||
<p><button type="submit">Log in</button></p>
|
||||
</form>
|
||||
|
||||
EOS
|
||||
@session.expects(:post_via_redirect)
|
||||
@session.clicks_button
|
||||
end
|
||||
|
||||
def test_should_not_explode_on_file_fields
|
||||
@response.stubs(:body).returns(<<-EOS)
|
||||
<form method="get" action="/form1">
|
||||
|
Loading…
Reference in New Issue
Block a user