From 57bad568f7377bcf1507294a465740d3d8b83496 Mon Sep 17 00:00:00 2001 From: Kanezoh Date: Tue, 29 Jun 2021 21:07:15 +0900 Subject: [PATCH] add Textarea --- src/mechanize/form.cr | 10 ++++++++++ src/mechanize/form/textarea.cr | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 src/mechanize/form/textarea.cr diff --git a/src/mechanize/form.cr b/src/mechanize/form.cr index 1e5d795..e640ef2 100644 --- a/src/mechanize/form.cr +++ b/src/mechanize/form.cr @@ -2,6 +2,7 @@ require "./form/field" require "./form/radio_button" require "./form/check_box" require "./form/text" +require "./form/textarea" require "./form/hidden" require "./form/button" require "./utils/element_matcher" @@ -70,10 +71,19 @@ class MechanizeCr::Form fields << FormContent::Text.new(html_node) when "hidden" fields << FormContent::Hidden.new(html_node) + when "textarea" + @fields << FormContent::Textarea.new(html_node) else fields << FormContent::Field.new(html_node) end end + + # Find all textarea tags + @node.css("textarea").each do |node| + node = node.as(Myhtml::Node) + next if node["name"].empty? + @fields << FormContent::Textarea.new(node, node.inner_text) + end end private def build_query_string(params : Array(Array(String))) diff --git a/src/mechanize/form/textarea.cr b/src/mechanize/form/textarea.cr new file mode 100644 index 0000000..53db27e --- /dev/null +++ b/src/mechanize/form/textarea.cr @@ -0,0 +1,2 @@ +class MechanizeCr::FormContent::Textarea < MechanizeCr::FormContent::Field +end