-
Notifications
You must be signed in to change notification settings - Fork 376
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
Action attribute not properly handled when selecting form #230
Comments
Hi, thanks for your interest in MechanicalSoup! I believe the issue is that you called the base class method
use
However, I recognize that the base class method does not make much sense in the context of using |
The obvious method to use when trying to submit a form is the `submit` method. Unless you are following the documentation explicitly, you may overlook the `submit_selected` method (which is really the only correct method to use when submitting a form within a StatefulBrowser instance). This is demonstrated by MechanicalSoup#230, where the user got an unexpected error because they used `submit` instead of `submit_selected`. To adhere to the principle of least astonishment, make `submit` a synonym for `submit_selected` (with `submit` being the primary name and `submit_selected` being an alias for backwards compatibility). This is a breaking change for anyone calling the base class `submit` from a StatefulBrowser instance. It is arguable that even if the call is made correctly, it is the "wrong" way to submit, so we should make it more difficult to "do the wrong thing". You can still access the base class `Browser.submit` from an instance of `StatefulBrowser` if you need to by using the `super` builtin, e.g. br = mechanicalsoup.StatefulBrowser() super(StatefulBrowser, br).submit(...)
This docstring note is a necessary (but probably not sufficient) change to `Browser.submit` to prevent it from being used in an inappropriate way from a `StatefulBrowser` instance. See MechanicalSoup#230 and MechanicalSoup#233 for more info.
This docstring note is a necessary (but probably not sufficient) change to `Browser.submit` to prevent it from being used in an inappropriate way from a `StatefulBrowser` instance. See MechanicalSoup#230 and MechanicalSoup#233 for more info.
Hello sir,
When I select a form from browser object the target URL doesn't handle relative paths and raises an error as it can be seen in the screenshot provided below.
Error was produced when the following code was run:
import mechanicalsoup
b=mechanicalsoup.StatefulBrowser()
r=b.open('https://google.co.in')
form=b.select_form(nr=0)
form.input({'q':'parrot'})
b.submit(form)
The text was updated successfully, but these errors were encountered: