mechanize:Mechanize::Form#button_with, #button
以下のような HTML で
<html> <head> <title>form test</title> </head> <body> <form method="get" action="cgi/foo00.cgi" name="form1"> <input type="submit" value="Send" /> <input type="reset" value="Cancel" /> </form> </body> </html>
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb74fb5ac ... >> page = agent.get('http://127.0.0.1:8080/test11_button.html') => #<Mechanize::Page {url #<URI::HTTP:0xb74f4f68 URL:http://127.0.0.1:8080/test11_button.html>} {meta} {title "form test"} {iframes} {frames} {links} {forms #<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads} {buttons #<Mechanize::Form::Submit:0xb74ec584 @name=nil, @node= #(Element:0x..fdba7634e { name = "input", attributes = [ #(Attr:0x..fdba74864 { name = "type", value = "submit" }), #(Attr:0x..fdba7485a { name = "value", value = "Send" })] }), @value="Send">}>}> >> f = page.form('form1') => #<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons} {checkboxes} {file_uploads} {buttons #<Mechanize::Form::Submit:0xb74ec584 @name=nil, @node= #(Element:0x..fdba7634e { name = "input", attributes = [ #(Attr:0x..fdba74864 { name = "type", value = "submit" }), #(Attr:0x..fdba7485a { name = "value", value = "Send" })] }), @value="Send">}> >> f.button_with(:value => "Send") => #<Mechanize::Form::Submit:0xb74ec584 @name=nil, @value="Send", @node=#<Nokogiri::XML::Element:0x..fdba7634e name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba74864 name="type" value="submit">, #<Nokogiri::XML::Attr:0x..fdba7485a name="value" value="Send">]>> >> f.button(:value => "Send") => #<Mechanize::Form::Submit:0xb74ec584 @name=nil, @value="Send", @node=#<Nokogiri::XML::Element:0x..fdba7634e name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba74864 name="type" value="submit">, #<Nokogiri::XML::Attr:0x..fdba7485a name="value" value="Send">]>> >> f.button_with(:value => "Send").value = 'send' => "send" >> f.button_with(:value => "Send") => nil >> f.button_with(:value => "send") => #<Mechanize::Form::Submit:0xb74ec584 @name=nil, @value="send", @node=#<Nokogiri::XML::Element:0x..fdba7634e name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba74864 name="type" value="submit">, #<Nokogiri::XML::Attr:0x..fdba7485a name="value" value="Send">]>>