From: Aaron Patterson Date: 2006-11-24T04:16:48+09:00 Subject: Re: mechanize question On Tue, Nov 21, 2006 at 10:46:26PM +0900, Peter Szinek wrote: > Peter Szinek wrote: > >Hello, > > > >I am using mechanize 0.6.3. On Aaron's blog I have found this example: > > > >form.selectlist.options[2].select > > > >however, for me, 'puts form.methods.sort' revealed that form does not > >have a method 'selectlist'. What's up? I am doing something wrong? > > Meanwhile, after browsing the RDoc of WWW::Mechanize::GlobalForm I have > found that indeed, Form does not have a selectlist method. > > OK but then How I am supposed to get the selectlist of a form? The select list is treated like a regular field. Say you have a select list with name 'foo', you could find it like this: form.fields.name('foo') -or, with method missing magic- form.foo > > the $1.000.000 question: In the same RDoc I read this: > > 'Class Form does not work in the case there is some invalid (unbalanced) > html involved...' > > Well, on my page, the
tag is not even closed. Can this be fixed > somehow? Mechanize uses HPricot for its HTML parsing. If Hpricot can handle the form tag that isn't closed, then you should be fine. If HPricot cannot handle the unbalanced form tag, you can write a pluggable parser to fix up your HTML before it is run through HPricot. > > Thanks, > Peter > > __ > http://www.rubyrailways.com > > Hope that helps. --Aaron -- Aaron Patterson http://tenderlovemaking.com/