sparklemotion / mechanize

Mechanize is a ruby library that makes automated web interaction easy.
https://www.rubydoc.info/gems/mechanize/
MIT License
4.39k stars 473 forks source link

Feature request: print a warning if you call `Form#submit` without specifying a `button` if there are multiple #624

Open Nakilon opened 11 months ago

Nakilon commented 11 months ago

Just spent an hour or more installing different debugging tools until found the cause of my error.

flavorjones commented 11 months ago

Hi @Nakilon, sorry you experienced this problem. Would you be interested in attempting to implement this in a pull request?

weshatheleopard commented 2 months ago

I think it can be handled by modifying Form#submit:

  def submit button = nil, headers = {}
+    warn "Multiple SUBMIT buttons available on the form." if submits.size > 1
    @mech.submit(self, button, headers)
  end
flavorjones commented 2 months ago

@weshatheleopard Thanks, I'd love a PR for this if you have the time and inclination.