I am using Mechanize to crawl a site that requires login. The following code logs me in.
require 'mechanize'
agent = Mechanize.new
agent.get 'http://www.specialsite.com'
agent.page.form.txtEmail = 'myemail@email.com'
agent.page.form.txtPassword = 'myPassword'
agent.page.form.add_field! "__EVENTTARGET","btnLogin"
agent.page.form.add_field! "__EVENTARGUMENT",""
agent.page.form.submit
agent.page.link_with(:text => "Special Link").click
agent.page.form.txtSearch = "Search Text"
agent.page.form.add_field! "__EVENTTARGET","lbtnSearch"
agent.page.form.add_field! "__EVENTARGUMENT",""
agent.page.form.submit
My question is, how do I run this code in the ruby IRB so that I can have access to the objects it defines like 'agent' to experiment with and generate the rest of the code I need?
I have tried 'load'. It runs the commands but it doesn't make the objects like 'agent' available.