add button form_test

This commit is contained in:
Kanezoh 2021-06-19 06:16:36 +09:00
parent c627106259
commit acbd92c79a
2 changed files with 18 additions and 5 deletions

View File

@ -8,12 +8,21 @@ WebMock.stub(:get, "example.com/check_form").to_return(body:
</head> </head>
<body> <body>
<form action="post_path" method="post" name="sample_form"> <form action="post_path" method="post" name="sample_form">
<!-- fields -->
<input type="text" name="name"> <input type="text" name="name">
<input type="text" name="email"> <input type="text" name="email">
<input type="hidden" name="userid" value="12345">
<input type="password" id="pass" name="password">
<!-- checkbox -->
<input type="checkbox" id="remember_me" name="remember_me" checked> <input type="checkbox" id="remember_me" name="remember_me" checked>
<!-- radiobuttons -->
<input type="radio" id="contactChoice1" name="contact" value="email"> <input type="radio" id="contactChoice1" name="contact" value="email">
<input type="radio" id="contactChoice2" name="contact" value="phone"> <input type="radio" id="contactChoice2" name="contact" value="phone">
<input type="radio" id="contactChoice3" name="contact" value="mail"> <input type="radio" id="contactChoice3" name="contact" value="mail">
<!-- buttons -->
<input type="button" value="pushit">
<input type="reset" value="no">
<input type="submit" value="submit">
</form> </form>
</body> </body>
</html> </html>
@ -33,7 +42,11 @@ describe "Mechanize Form test" do
form.name.should eq "sample_form" form.name.should eq "sample_form"
end end
it "includes fields" do it "includes fields, radiobuttons, checkboxes, buttons" do
form.fields.size.should eq 2 # fields: input type = (text,hidden, or others)
form.fields.size.should eq 4
form.checkboxes.size.should eq 1
form.radiobuttons.size.should eq 3
form.buttons.size.should eq 3
end end
end end

View File

@ -83,11 +83,11 @@ class MechanizeCr::Form
when "radio" when "radio"
radiobuttons << FormContent::RadioButton.new(html_node, self) radiobuttons << FormContent::RadioButton.new(html_node, self)
when "button" when "button"
@buttons << FormContent::Button.new(html_node) buttons << FormContent::Button.new(html_node)
when "submit" when "submit"
@buttons << FormContent::SubmitButton.new(html_node) buttons << FormContent::SubmitButton.new(html_node)
when"reset" when"reset"
@buttons << FormContent::ResetButton.new(html_node) buttons << FormContent::ResetButton.new(html_node)
when "text" when "text"
fields << FormContent::Text.new(html_node) fields << FormContent::Text.new(html_node)
when "hidden" when "hidden"