views:

161

answers:

2

I'm trying to submit a form on an .asp page but Mechanize does not recognize the name of the control. The form code is:

<form id="form1" name="frmSearchQuick" method="post">
....
<input type="button" name="btSearchTop" value="SEARCH" class="buttonctl" onClick="uf_Browse('dledir_search_quick.asp');" >

My code is as follows:

br = mechanize.Browser()
br.open(BASE_URL)
br.select_form(name='frmSearchQuick')
resp = br.click(name='btSearchTop')

I've also tried the last line as:

resp = br.submit(name='btSearchTop')

The error I get is:

raise ControlNotFoundError("no control matching "+description) ControlNotFoundError: no control matching name 'btSearchTop', kind 'clickable'

If I print br I get this: IgnoreControl(btSearchTop=)

But I don't see that anywhere in the HTML.

Any advice on how to submit this form?

+3  A: 

The button doesn't submit the form - it calls some javascript function.

Mechanize can't run javascript, so you can't use it to click that button.

The easy way out is to read that function yourself, and see what it does - if it just submits the form, then maybe you can get around it by submitting the form without clicking on anything.

nosklo
A: 

you need to inspect element first, did mechanize recognize the form ?

for form in br.forms():
       print form
Gunslinger_