diff --git a/spec/form/field_spec.cr b/spec/form/field_spec.cr index 7079e52..26365f1 100644 --- a/spec/form/field_spec.cr +++ b/spec/form/field_spec.cr @@ -8,7 +8,7 @@ WebMock.stub(:get, "example.com/form/fields").to_return(body:
@@ -24,5 +24,7 @@ describe "Form Fields" do field = form.fields.first field.type.should eq "text" field.name.should eq "name" + field.value.should eq "kanezoh" + field.raw_value.should eq "kanezoh" end end diff --git a/src/mechanize/form/field.cr b/src/mechanize/form/field.cr index bcff113..7ecd22f 100644 --- a/src/mechanize/form/field.cr +++ b/src/mechanize/form/field.cr @@ -10,10 +10,20 @@ class MechanizeCr::FormContent::Field @name = node.fetch("name", "") @value = value || node.fetch("value", nil) @type = node.fetch("type", "") - @raw_value = value + @raw_value = @value end def query_value [@name, @value || ""] end + + # returns DOM 'id' value + def dom_id + node.fetch("id", "") + end + + # returns DOM 'class' value + def dom_class + node.fetch("class", "") + end end