On Sun, Aug 06, 2006 at 06:05:04AM +0900, barjunk wrote: [snip]
Agreed. This is not very intuitive, which is something I believe I've
fixed in 0.5.2 (which isn't released yet). In 0.5.2 you'll be able to
say:
selectlist.options.first.click
or
selectlist.options.first.select
Maybe a hint about how to go through the API to get the answer for
myself?
Check out the EXAMPLES file. I've also tried to put examples in many
classes, though I will add more for the next release. I've also got a
few one liners in my blog:
http://tenderlovemaking.com/2006/05/26/mechanize-one-liners/
One additional question I have is, what if there is more than one form
on the page?
Forms are just stored as an array on the Page object returned to you by
mechanize. You can treat them like an array, or better yet use the name
of the form to find the right one to deal with.
To find the first form, you could do either of these:
page.forms.first
page.forms[0]
To find a form with the name "foo", you can do either of these:
page.forms.with.name('foo').first
page.forms.name('foo').first
Take a look at the "Google" example in the RDoc example page. The
EXAMPLES Rdoc, and the NOTES Rdoc should be pretty helpful.