Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot submit form with multiple identical submits #264

Closed
ricecooker opened this issue Jan 24, 2019 · 3 comments
Closed

Cannot submit form with multiple identical submits #264

ricecooker opened this issue Jan 24, 2019 · 3 comments

Comments

@ricecooker
Copy link

When I have a form like:

<form action="#" method="POST" name="blah">
  <input type="submit" name="search" value="Search"/>
  <input type="submit" name="search" value="Search"/>
</form>

There isn't a way to submit the form. It will always raise a LinkNotFoundError.

Around form.py:333 I'd do

if inp == submit and found: 
  del inp['name']
ricecooker pushed a commit to sstm2/MechanicalSoup that referenced this issue Feb 26, 2019
Closes MechanicalSoup#264.

MechanicalSoup was incorrectly raising a LinkNotFoundError
if a form had duplicate <input type='submit'/>.

This patch works by checking the form parameters on submit. If
there are duplicates to the selected submit button, they are
ignored when building the dictionary of form values.
ricecooker pushed a commit to sstm2/MechanicalSoup that referenced this issue Feb 26, 2019
Closes MechanicalSoup#264.

MechanicalSoup was incorrectly raising a LinkNotFoundError
if a form had duplicate <input type='submit'/>.

This patch works by checking the form parameters on submit. If
there are duplicates to the selected submit button, they are
ignored when building the dictionary of form values.
@moy moy closed this as completed in 10baed4 Mar 12, 2019
@nk9
Copy link

nk9 commented Aug 12, 2019

Thanks for fixing this. The last release was from a year ago, though. If I need this now, what's the recommended branch? Just… master? gulp

@hemberger
Copy link
Contributor

I'm sure we could come up with a new release on fairly short order. I'll talk to @moy and we'll keep you posted.

@nk9
Copy link

nk9 commented Aug 13, 2019

That would be swell, thanks.

For others who may be running into the problem and are using v0.11.0 or earlier, I have found a simple solution:

submitEls = browser.get_current_page().find_all(type='submit')

# Remove excess submit elements
for index, submitEl in enumerate(submitEls):
    if index > 0:
        submitEl.extract()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants