views:

136

answers:

1
Watir::Browser.default = "firefox"
  ie = Watir::Browser.start("http://cars.com")

  ie.select_list(:id, 'make_1').set('Chevrolet')
  ie.select_list(:id, 'model_1').set('Cobalt')
  ie.select_list(:id, 'pricehighnew').set('No Max')
  ie.select_list(:id, 'rdnew').set('30 miles')
  ie.text_field(:name, "zc").set "44109"

  ie.form(:method, "GET").submit   #Here is the problem...

URL: http://www.cars.com/

Can anyone help me initiate button click action searching for "New Cars" form on the top left. Seems like they are using JavaScript as well. I appreciate any help.

+1  A: 

There's probably a way to do it with JavaScript, but taking just a minute I was able to click the button two different ways:

ie.span(:text=>"Search New").click

ie.link(:href=>"javascript:checkZipFirst(document.newForm, quickSubmitNew, document.newForm.zc.value);").click

marc