Skip to content

Commit

Permalink
browser: accept non-lowercase type="radio" and "checkbox"
Browse files Browse the repository at this point in the history
Fixes #245.
  • Loading branch information
moy committed Oct 13, 2018
1 parent c5fc375 commit 8cc5847
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion mechanicalsoup/browser.py
Expand Up @@ -163,7 +163,10 @@ def _request(self, form, url=None, **kwargs):
name = tag.get("name") # name-attribute of tag

if tag.name == "input":
if tag.get("type") in ("radio", "checkbox"):
if (
tag.get("type") is not None and
tag.get("type").lower() in ("radio", "checkbox")
):
if "checked" not in tag.attrs:
continue
value = tag.get("value", "on")
Expand Down
8 changes: 4 additions & 4 deletions tests/test_browser.py
Expand Up @@ -45,14 +45,14 @@ def test__request(httpbin):
<textarea name="comments">freezer</textarea>
<fieldset>
<legend> Pizza Size </legend>
<p><input type=radio name=size value="small">Small</p>
<p><input type=radio name=size value="medium" checked>Medium</p>
<p><input type=RADIO name=size value="small">Small</p>
<p><input type=radiO name=size value="medium" checked>Medium</p>
<p><input type=radio name=size value="large">Large</p>
</fieldset>
<fieldset>
<legend> Pizza Toppings </legend>
<p><input type=checkbox name="topping" value="bacon" checked>Bacon</p>
<p><input type=checkbox name="topping" value="cheese">Extra Cheese</p>
<p><input type=CHECKBOX name="topping" value="bacon" checked>Bacon</p>
<p><input type=checkBox name="topping" value="cheese">Extra Cheese</p>
<p><input type=checkbox name="topping" value="onion" checked>Onion</p>
<p><input type=checkbox name="topping" value="mushroom">Mushroom</p>
</fieldset>
Expand Down

0 comments on commit 8cc5847

Please sign in to comment.