Pylons / Pylons/webtest

webtest.forms.Radio() pays no attention to the 'disabled' attribute of <input type="radio">

Open
#212 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
346
Forks
113
PR merge metrics
No merged PRs in 30d

Description

I've a test helper that populates a form that I'm porting from mechanize to webtest. During this I've noticed that webtest ignores the disabled attribute on individual radio buttons. Given the following HTML:

<html>
  <form name="my_form" action="test.html"
        enctype="multipart/form-data" method="post">
    <input type="radio" name="radio-4" value="1" />
    <input type="radio" name="radio-4" value="2" />
    <input type="radio" name="radio-4" value="3" />
    <input type="radio" name="radio-4" value="4" disabled="disabled" />
    <input type="submit" name="submit" value="Submit" />
  </form>
</html>

if I feed it to webtest (via a very simple wsgi app) and access the form, the following things stand out,
form.fields['radio-4'].options lists all four options, including the disabled one.

Some interesting details that may be relevant:

  • print(form.html) doesn't even show "disabled" attributes
  • print(form.text) shows the disabled="disabled", but the HTML has been reformatted and doesn't match my actual HTML source

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied form HTML and inspect how webtest exposes form.fields['radio-4'].options. Trace the form helper that parses individual radio inputs; done means disabled radio options are handled consistently with the disabled attribute, with coverage for the supplied case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.