jmcarp / robobrowser

BSD 3-Clause "New" or "Revised" License
3.7k stars 337 forks source link

Error with two Submits #61

Open mrlucasrib opened 8 years ago

mrlucasrib commented 8 years ago

Hello, I have the following form:

<form action="/composer/mbasic/?av=100003111991563&amp;refid=18" method="post"><input autocomplete="off" name="fb_dtsg" type="hidden" value="AQG1ETPXS38n:AQGO2WaIwVNU"/><input name="charset_test" type="hidden" value="€,´,€,´,水,Д,Є"/><input name="target" type="hidden" value="208910505938561"/><input name="c_src" type="hidden" value="group"/><input name="cwevent" type="hidden" value="composer_entry"/><input name="referrer" type="hidden" value="group"/><input name="ctype" type="hidden" value="inline"/><input name="cver" type="hidden" value="amber"/><input name="rst_icv" type="hidden"/><label class="bw" for="u_0_0">Escreva algo...</label><table class="l bx"><tbody><tr><td class="r"><div class="by bz"><table class="l ca cb"><tbody><tr><td class="m cc"><label for="u_0_0"><img alt="João-Wellmara Ribeiro" class="cd img" height="32" src="https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfa1/v/t1.0-1/cp0/e15/q65/c193.2.623.623/s64x64/69216_424777024302694_750875852_n.jpg?efg=eyJpIjoiYiJ9&amp;oh=4d6b037d8e5f05a45336e23c363281f3&amp;oe=574B42B8&amp;__gda__=1465173705_7290807370b55f707b242f68bf5e22f1" width="32"/></label></td><td class="r ce bj"><textarea class="cf cg ch ci cj" id="u_0_0" name="xc_message" rows="2"></textarea></td></tr></tbody></table></div></td><td class="m"><div class="ck"><input class="w x z" name="view_post" type="submit" value="Publicar"/></div></td></tr></tbody></table><div class="cl"><span class="cm cn co"><div class="cp"><table class="l cq bj"><tbody><tr><td class="u m"><label class="cr" for="u_0_1"><img class="cs ct img" height="12" src="https://fbstatic-a.akamaihd.net/rsrc.php/v2/yd/r/10cmx89F1gU.png" width="12"/></label></td><td class="u m"><input class="w cu cv cw" id="u_0_1" name="view_photo" type="submit" value="Adicionar fotos"/></td></tr></tbody></table></div> <div class="cp"><table class="l cq bj"><tbody><tr><td class="u m"><label class="cr" for="u_0_2"><img class="cs ct img" height="12" src="https://fbstatic-a.akamaihd.net/rsrc.php/v2/yg/r/upxxJ9A52e7.png" width="12"/></label></td><td class="u m"><input class="w cu cv cw" id="u_0_2" name="view_overview" type="submit" value="Mais"/></td></tr></tbody></table></div></span></div></form>

it has two Submits the view_post and view_photo. I'm trying to send the view_post but I'm not succeeding

>>> br.submit_form(form, form.fields['view_post']) Traceback (most recent call last): File "<input>", line 1, in <module> File "C:\Users\lmr21\AppData\Local\Programs\Python\Python35\lib\site-packages\robobrowser\browser.py", line 339, in submit_form payload = form.serialize(submit=submit) File "C:\Users\lmr21\AppData\Local\Programs\Python\Python35\lib\site-packages\robobrowser\forms\form.py", line 227, in serialize return Payload.from_fields(include_fields) File "C:\Users\lmr21\AppData\Local\Programs\Python\Python35\lib\site-packages\robobrowser\forms\form.py", line 118, in from_fields if not field.disabled: AttributeError: 'str' object has no attribute 'disabled'

I'm getting this error .. what am I doing wrong?

ghost commented 8 years ago

I had a similar problem, but with robobrowser.exceptions.InvalidSubmitError. This is how I solved it:

submit_field = my_form['action']
submit_field.value = 'Authorize'
browser.submit_form(my_form, submit=submit_field)
busbyjon commented 7 years ago

👍 - this fixed it for me, again, the symptom appears to be multiple submit buttons.

There must be another way to fix this!