diff --git a/spec/form/textarea_spec.cr b/spec/form/textarea_spec.cr
new file mode 100644
index 0000000..074d422
--- /dev/null
+++ b/spec/form/textarea_spec.cr
@@ -0,0 +1,27 @@
+require "../spec_helper"
+
+WebMock.stub(:get, "example.com/form/textarea").to_return(body:
+<<-BODY
+
+
+ page_title
+
+
+
+
+
+BODY
+)
+
+describe "Form Fields CheckBox" do
+ agent = Mechanize.new
+ page = agent.get("http://example.com/form/textarea")
+ form = page.forms[0]
+
+ it "returns textareas" do
+ form.textareas.size.should eq 2
+ end
+end
diff --git a/src/mechanize/form.cr b/src/mechanize/form.cr
index e640ef2..447a72f 100644
--- a/src/mechanize/form.cr
+++ b/src/mechanize/form.cr
@@ -52,6 +52,11 @@ class MechanizeCr::Form
elements_with "radiobutton"
elements_with "checkbox", "checkboxes"
+ # Returns all fields of type Textarea
+ def textareas
+ fields.select { |f| f.class == FormContent::Textarea }.map &.as(FormContent::Textarea)
+ end
+
private def parse
@node.css("input").not_nil!.each do |html_node|
html_node = html_node.as(Myhtml::Node)
@@ -72,7 +77,7 @@ class MechanizeCr::Form
when "hidden"
fields << FormContent::Hidden.new(html_node)
when "textarea"
- @fields << FormContent::Textarea.new(html_node)
+ fields << FormContent::Textarea.new(html_node)
else
fields << FormContent::Field.new(html_node)
end