0

I want to fill out the calendar date field for www.vegas.com/lasvegastraveldeals.

So far I can't seem to get the value method to work. Here is my code:

require 'mechanize'

agent = Mechanize.new
page = agent.get('http://www.vegas.com/lasvegastraveldeals/')
vegas_form = page.form('gs')
vegas_form.q = 'DFW'
departure = vegas_form.field_with(:id => 'departureDatec12')
departure.value = "05/16/2014"
pp page

I get this error:

vegas_scraper.rb:9:in `<main>': undefined method `value=' for nil:NilClass (NoMethodError)

Any suggestions?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Seal
  • 1,060
  • 1
  • 12
  • 31

2 Answers2

1

If the field name is departureDate then this should work:

form['departureDate'] = '05/16/2014'
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
pguardiario
  • 53,827
  • 19
  • 119
  • 159
0

You are not finding the input with id departureDatec12. According to the source code of the page it is departureDate2. So try with this

departure = vegas_form.field_with(:id => 'departureDate2')
Rafa Paez
  • 4,820
  • 18
  • 35