12

I have a form with <input type="button" name="submit" /> button and would like to be able to click it.

I have tried mech.form.click("submit") but that gives the following error:

ControlNotFoundError: no control matching kind 'clickable', id 'submit'

mech.submit() also doesn't work since its type is button and not submit.

Any ideas? Thanks.

nunos
  • 19,269
  • 49
  • 116
  • 153

1 Answers1

21

clicking a type="button" in a pure html form does nothing. For it to do anything, there must be javascript involved.

And mechanize doesn't run javascript.

So your options are:

  • Read the javascript yourself and simulate with mechanize what it would be doing
  • Use spidermonkey to run the javascript code

I'd do the first one, since using spidermonkey seems hard and probably not worth it.

nosklo
  • 205,639
  • 55
  • 286
  • 290
  • 1
    This was a long time ago, but what do you mean by "stimulate with mechanize"? – Constantly Confused Jan 13 '16 at 13:30
  • @nosklo yes.. sames question here.... how do you simulate javascript with mechanice? – waas1919 Apr 29 '16 at 16:19
  • 1
    @waas1919 you have to read the javascript code and understand what it does. For example, if the javascript code submits the form to a different address, then you write python code to do that manually. If the javascript code changes the value of some field, then you must do the change by hand in your python code. – nosklo May 06 '16 at 20:10