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

Submit form with no button #403

Closed
alexreg opened this issue Jun 17, 2022 · 4 comments · Fixed by #411
Closed

Submit form with no button #403

alexreg opened this issue Jun 17, 2022 · 4 comments · Fixed by #411

Comments

@alexreg
Copy link
Contributor

alexreg commented Jun 17, 2022

Some web pages use JavaScript postbacks to submit forms. This means that a submitted form has nothing to do with which button is pressed. In fact, including form data for the "pressed" button can mess things up in such a case.

Accordingly, it would be great to have a way of specifying that no button "press" should be simulated when calling submit_selected. Right now, btnName = None means that the first "submit" button is auto-selected — but there is no way to specify that no submit button press should be simulated. Perhaps another (boolean) parameter could be used for this? The Form.choose_submit method would also need to be enhanced accordingly.

@hemberger
Copy link
Contributor

Sorry for the excessively slow reply to this issue! I see your point about having no way to specify that no submit button should be simulated. If this is still relevant to you, we can certainly consider an enhancement here. Maybe the simplest thing would be to skip selecting a submit if btnName=False (to avoid needing to handle all the combinations of btnName with some additional boolean flag):

if btnName is not False:
    self.form.choose_submit(btnName)

You can also use Browser.submit directly, but obviously that doesn't help if you want to use StatefulBrowser features with this.

@alexreg
Copy link
Contributor Author

alexreg commented Dec 5, 2022

@hemberger Thanks for getting back to me. Yes, I'd certainly still be keen to see this feature implemented. The way you've suggested seems like a very simple change, and would no doubt work for me.

@moy
Copy link
Collaborator

moy commented Dec 6, 2022

If you have time to work on it, pull-requests are welcome (the code itself should be straightforward, but there should be a test which may require a bit more time to write). We may get time to implement it ourselves, but at least I have very limited time for MechanicalSoup :-(.

@alexreg
Copy link
Contributor Author

alexreg commented Dec 6, 2022

@moy Okay, sure.

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

Successfully merging a pull request may close this issue.

3 participants