tags:

views:

39

answers:

1

http://casesearch.courts.state.md.us/inquiry/inquirySearchParam.jis

agent   = Mechanize.new
form    = agent.get("http://casesearch.courts.state.md.us/inquiry/inquiry-index.jsp").forms.first
form.checkbox_with(:name => /disclaimer/).check
page    = form.submit

The above code submits the discalimer in the above website. Now after submitting the disclaimer note, When I use the following code..

p page.forms[2]

It should output all the fields including first name,last name and all the lists [As you can see on the website] but it is not doing so. Instead i just get the information about textboxes.

Can anyone tell me why? Despite the form[2] being the specific form on that page which contains most of the fields?

A: 

It looks like forms[3] contains the info that you are looking for. Are you starting you count at 1 instead of 0?

require 'rubygems'
require 'mechanize'

agent   = Mechanize.new
form    = agent.get("http://casesearch.courts.state.md.us/inquiry/inquiry-  index.jsp").forms.first
form.checkbox_with(:name => /disclaimer/).check
page    = form.submit

p page.forms.count  
# out puts 4

p page.forms[3] 
# outputs what I think you need


#<Mechanize::Form
 {name "inquiryFormByCaseNum"}
 {method "POST"}
 {action "/inquiry/inquiryByCaseNum.jis"}
 {fields
  #<Mechanize::Form::Text:0x000001011cd020
  @name="caseId",
  @node=
Future429
No dude, thats not the case. The fields in the form[3] are completely different from which I except. But thanks for looking for the problem. I think the problem is with valid/invalid HTML.
Shubham
Chrome developer tools show an error on the page related to the form. "<form> cannot act as container inside <table> without disrupting the table. The children of the <form> will be placed inside the <table> instead".
Future429