Christopher Rasch
2009-Sep-23 00:26 UTC
[Mechanize-users] Handling form fields with "." in them?
Hi, Upon re-installing mechanize on a new machine, I found that the API had changed, and I''m having trouble figuring out how to upgrade my script to account for the new changes. The following used to work: page = @agent.get ''http://www.example.com'' login_form = page.forms.with.name("loginForm").first login_form.fields.name("mbr.loginID").value= CONFIG[''example''][''login''] login_form.fields.name("mbr.password").value=CONFIG[''example''][''password''] page = @agent.submit(login_form) return page This is what I think the new script should be: page = login_page.form_with(:name => "loginForm") do |f| f.mbr.loginID = CONFIG[''example''][''login''] f.mbr.password = CONFIG[''example''][''password''] end.submit However, I get the following error: /usr/local/lib/ruby/gems/1.8/gems/visionmedia-commander-3.2.9/lib/commander/user_interaction.rb:101:in `method_missing'': undefined method `mbr'' for #<WWW::Mechanize::Form:0x2ab9e04> (NoMethodError) The . in the field name appears to be interpreted as a method indicator. What would be the best way of referencing and assigning values to the form fields name "mbr.loginID" and "mbr.password"? Thanks! Chris