From: barjunk Date: 2006-08-06T15:20:09+09:00 Subject: Re: Mechanize Aaron Patterson wrote: > 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. > This was helpful also, thanks. I hadn't thought of reading the NOTES Rdoc, so thanks for that idea as well. I'm not sure how the "Google" example helps me, I must be missing something obvious...in addition to being new to ruby, I'm also new to HTML and that might make more "obvious" things not so obvious. :) Thanks again Aaron. I really enjoy using Mechanize...it saved me tons of time. Mike B.