When I run this code:
require 'mechanize'
require 'logger'
require 'nokogiri'
require 'open-uri'
agent = Mechanize.new
agent.log = Logger.new "mech.log"
agent.user_agent_alias = 'Mac Safari'
agent.verify_mode = OpenSSL::SSL::VERIFY_NONE
page = agent.get('https://sarathi.nic.in:8443/nrportal/sarathi/HomePage.jsp')
page = agent.page.links.find{|i| i.text == "Status of Licence"}.click
page.form(:name=>"dlform").field_with(:name=>"dlform:DLNumber").value="TN4020120005045"
page.submit
I get this error:
NoMethodError: undefined method `submit' for #<Mechanize::Page:0x8e644cc>
How can I solve this?
@sudhagar, you should submit the form rather than the page. Also break it into separate calls for a cleaner code, as:
...
form = page.form(:name=>"dlform")
form.field_with(:name=>"dlform:DLNumber").value="TN4020120005045"
form.submit
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With