1

I'm having trouble returning the results page after using Mechanize (in Ruby) to auto enter search fields and auto click submit button.

The problem is that the 3 second loading page gets returned, NOT the actual results page which loads a few seconds later.

Putting a sleep in there obviously isn't working.

require 'mechanize'

agent = Mechanize.new
url = 'https://www.intelius.com'
agent.get(url) do |page|
    form = page.forms.first

    username_field = form.field_with(:id => "peopleSearch_firstName")
    username_field.value = "John"
    password_field = form.field_with(:id => "peopleSearch_lastName")
    password_field.value = "Lee"
    city_state_field = form.field_with(:id => "peopleSearch_cityState")
    city_state_field.value = "Van Nuys, CA"

    page_logged_in = form.submit
    sleep(5)
    puts page_logged_in.body
end
heebee313
  • 325
  • 1
  • 5
  • 16
  • I've flagged you're question as a duplicate of [this one](https://stackoverflow.com/a/802281) because your problem seems to be that the page depends on javascript but mechanize doesn't execute javascript. – thesecretmaster Aug 11 '18 at 17:59

0 Answers0