Reputation: 504
I need to simulate the submit action on a form that has 2 options for submit button with both the options having the same name
attribute. Here's how they look using the Inspect tool:
So, they differ in their id
and value
attributes but not the name
attribute.
The problem I am having is that the submit_selected()
method in MechanicalSoup
only accepts Button Name as the parameter:
submit_selected(btnName=None, *args, **kwargs)
So how can I use this method to uniquely select the appropriate button?
Upvotes: 0
Views: 1340
Reputation: 187
If I'm not mistaken, you can use other attributes. For instance, we can use id or value from your example as they are not identical. like so....
my_button = br.get_current_page().find('input', id='edit-save')
br.submit_selected(btnName=my_button)
my_button = br.get_current_page().find('input', value='Search')
br.submit_selected(btnName=my_button)
Upvotes: 0
Reputation: 16647
Use Form.choose_submit. This function can receive a BeautifulSoup Tag element, so you can use whatever BeautifulSoup provides to select the right submit button.
Upvotes: 0