Hello.
I have run into a new form that contains multiple submit buttons.
Currently my code for working with forms looks just like this example.
require ''rubygems''
require ''mechanize''
a = WWW::Mechanize.new { |agent|
agent.user_agent_alias = ''Mac Safari''
}
a.get(''http://google.com/'') do |page|
search_result = page.form_with(:name => ''f'') do
|search|
search.q = ''Hello world''
end.submit
search_result.links.each do |link|
puts link.text
end
end
But now I have 2 <input type=submit.> values on my form. How can I tell
Mechanize which submit button to use to get to the result set?
Thanks!
Cindy
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/mechanize-users/attachments/20081103/f3a1c807/attachment.html>
Hello.
Sorry if this is double posted, but I didn''t see it come through the
mailing
list yet.
I have run into a new form that contains multiple submit buttons.
Currently my code for working with forms looks just like this example.
require ''rubygems''
require ''mechanize''
a = WWW::Mechanize.new { |agent|
agent.user_agent_alias = ''Mac Safari''
}
a.get(''http://google.com/'') do |page|
search_result = page.form_with(:name => ''f'') do
|search|
search.q = ''Hello world''
end.submit
search_result.links.each do |link|
puts link.text
end
end
But now I have 2 <input type=submit.> values on my form. How can I tell
Mechanize which submit button to use to get to the result set?
Thanks!
Cindy
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/mechanize-users/attachments/20081103/0d4a66d5/attachment.html>
On Mon, Nov 03, 2008 at 12:06:05PM -0600, Cindy Schaller wrote:> Hello. > > > > I have run into a new form that contains multiple submit buttons. > > > > Currently my code for working with forms looks just like this example. > > > > require ''rubygems'' > require ''mechanize'' > > a = WWW::Mechanize.new { |agent| > agent.user_agent_alias = ''Mac Safari'' > } > > a.get(''http://google.com/'') do |page| > search_result = page.form_with(:name => ''f'') do |search| > search.q = ''Hello world'' > end.submit > > search_result.links.each do |link| > puts link.text > end > endSubmit takes an argument which is the button to use. You can probably do something like this: a.get(''http://google.com/'') do |page| search_result = page.form_with(:name => ''f'') do |search| search.q = ''Hello world'' end.submit(page.form_with(:name => ''f'').buttons[1]) end -- Aaron Patterson http://tenderlovemaking.com/