mechanize:Mechanize::Form#radiobutton_with, #radiobutton
以下のような HTML で
<html> <head> <title>form test</title> </head> <body> <form method="get" action="cgi/foo00.cgi" name="form1"> <input type="radio" name="radio1" value="foo" checked="checked" />Foo <input type="radio" name="radio1" value="bar" />Bar </form> </body> </html>
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb745c538 ... >> page = agent.get('http://127.0.0.1:8080/test13_radiobutton.html') => #<Mechanize::Page ... >> f = page.form('form1') => #<Mechanize::Form ... >> f.radiobutton_with(:name => "radio1") => #<Mechanize::Form::RadioButton:0xb744ff7c @checked=true, @name="radio1", @value="foo", @form=#<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons #<Mechanize::Form::RadioButton:0xb744ff7c @checked=true, @name="radio1", @value="foo"> #<Mechanize::Form::RadioButton:0xb744fe14 @checked=false, @name="radio1", @value="bar">} {checkboxes} {file_uploads} {buttons}> , @node=#<Nokogiri::XML::Element:0x..fdba2802c name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba1df00 name="type" value="radio">, #<Nokogiri::XML::Attr:0x..fdba1def6 name="name" value="radio1">, #<Nokogiri::XML::Attr:0x..fdba1deec name="value" value="foo">, #<Nokogiri::XML::Attr:0x..fdba1dee2 name="checked" value="checked">]>> >> f.radiobutton_with(:value => "bar") => #<Mechanize::Form::RadioButton:0xb744fe14 @checked=false, @name="radio1", @value="bar", @form=#<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons #<Mechanize::Form::RadioButton:0xb744ff7c @checked=true, @name="radio1", @value="foo"> #<Mechanize::Form::RadioButton:0xb744fe14 @checked=false, @name="radio1", @value="bar">} {checkboxes} {file_uploads} {buttons}> , @node=#<Nokogiri::XML::Element:0x..fdba27fdc name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba1afee name="type" value="radio">, #<Nokogiri::XML::Attr:0x..fdba1afe4 name="name" value="radio1">, #<Nokogiri::XML::Attr:0x..fdba1afda name="value" value="bar">]>> >> f.radiobutton(:value => "bar") => #<Mechanize::Form::RadioButton:0xb744fe14 @checked=false, @name="radio1", @value="bar", @form=#<Mechanize::Form {name "form1"} {method "GET"} {action "cgi/foo00.cgi"} {fields} {radiobuttons #<Mechanize::Form::RadioButton:0xb744ff7c @checked=true, @name="radio1", @value="foo"> #<Mechanize::Form::RadioButton:0xb744fe14 @checked=false, @name="radio1", @value="bar">} {checkboxes} {file_uploads} {buttons}> , @node=#<Nokogiri::XML::Element:0x..fdba27fdc name="input" attributes=[#<Nokogiri::XML::Attr:0x..fdba1afee name="type" value="radio">, #<Nokogiri::XML::Attr:0x..fdba1afe4 name="name" value="radio1">, #<Nokogiri::XML::Attr:0x..fdba1afda name="value" value="bar">]>>