mechanize:Mechanize::Page::Label#page
以下のような HTML で
<html> <head> <title>label test</title> </head> <body> <form method="post" action="cgi/test_form00.cgi" name="form1"> <input type="radio" name="radio1" id="r1" value="male" checked="checked"><label for="r1">Male</label> <input type="radio" name="radio1" id="r2" value="female"><label for="r2">Female</label> </form> </body> </html>
>> require 'mechanize' => true >> agent = Mechanize.new => #<Mechanize:0xb74e9604 ... >> page = agent.get('http://127.0.0.1:8080/test05_label.html') => #<Mechanize::Page {url #<URI::HTTP:0xb74e5ce8 URL:http://127.0.0.1:8080/test05_label.html>} {meta} {title "label test"} {iframes} {frames} {links} {forms #<Mechanize::Form {name "form1"} {method "POST"} {action "cgi/test_form00.cgi"} {fields} {radiobuttons #<Mechanize::Form::RadioButton:0xb74dd32c @checked=true, @name="radio1", @value="male"> #<Mechanize::Form::RadioButton:0xb74dd1c4 @checked=false, @name="radio1", @value="female">} {checkboxes} {file_uploads} {buttons}>}> >> page.labels[0].page => #<Mechanize::Page {url #<URI::HTTP:0xb74e5ce8 URL:http://127.0.0.1:8080/test05_label.html>} {meta} {title "label test"} {iframes} {frames} {links} {forms #<Mechanize::Form {name "form1"} {method "POST"} {action "cgi/test_form00.cgi"} {fields} {radiobuttons #<Mechanize::Form::RadioButton:0xb74dd32c @checked=true, @name="radio1", @value="male"> #<Mechanize::Form::RadioButton:0xb74dd1c4 @checked=false, @name="radio1", @value="female">} {checkboxes} {file_uploads} {buttons}>}> >> page.labels[1].page => #<Mechanize::Page {url #<URI::HTTP:0xb74e5ce8 URL:http://127.0.0.1:8080/test05_label.html>} {meta} {title "label test"} {iframes} {frames} {links} {forms #<Mechanize::Form {name "form1"} {method "POST"} {action "cgi/test_form00.cgi"} {fields} {radiobuttons #<Mechanize::Form::RadioButton:0xb74dd32c @checked=true, @name="radio1", @value="male"> #<Mechanize::Form::RadioButton:0xb74dd1c4 @checked=false, @name="radio1", @value="female">} {checkboxes} {file_uploads} {buttons}>}>