Public Member Functions | |
| def | __getitem__ |
| def | __init__ |
| def | __repr__ |
| def | __setitem__ |
| def | get |
| def | lint |
| def | select |
| def | select_multiple |
| def | set |
| def | submit |
| def | submit_fields |
| def | upload_fields |
Public Attributes | |
| action | |
| enctype | |
| field_order | |
| fields | |
| html | |
| id | |
| method | |
| response | |
| text | |
Static Public Attributes | |
| FieldClass = Field | |
Private Member Functions | |
| def | _parse_fields |
Static Private Attributes | |
| tuple | _label_re |
| tuple | _tag_re = re.compile(r'<(/?)([a-z0-9_\-]*)([^>]*?)>', re.I) |
This object represents a form that has been found in a page.
:param response: `webob.response.TestResponse` instance
:param text: Unparsed html of the form
.. attribute:: text
the full HTML of the form.
.. attribute:: action
the relative URI of the action.
.. attribute:: method
the HTTP method (e.g., ``'GET'``).
.. attribute:: id
the id, or None if not given.
.. attribute:: enctype
encoding of the form submission
.. attribute:: fields
a dictionary of fields, each value is a list of fields by
that name. ``<input type=\"radio\">`` and ``<select>`` are
both represented as single fields with multiple options.
.. attribute:: field_order
Ordered list of field names as found in the html.
| def webtest.forms.Form.__init__ | ( | self, | |
| response, | |||
| text, | |||
parser_features = 'html.parser' |
|||
| ) |
| def webtest.forms.Form.__getitem__ | ( | self, | |
| name | |||
| ) |
| def webtest.forms.Form.__repr__ | ( | self | ) |
| def webtest.forms.Form.__setitem__ | ( | self, | |
| name, | |||
| value | |||
| ) |
Set the value of the named field. If there is 0 or multiple fields by that name, it is an error. Multiple checkboxes of the same name are special-cased; a list may be assigned to them to check the checkboxes whose value is present in the list (and uncheck all others). Setting the value of a ``<select>`` selects the given option (and confirms it is an option). Setting radio fields does the same. Checkboxes get boolean values. You cannot set hidden fields or buttons. Use ``.set()`` if there is any ambiguity and you must provide an index.
| def webtest.forms.Form._parse_fields | ( | self | ) | [private] |
| def webtest.forms.Form.get | ( | self, | |
| name, | |||
index = None, |
|||
default = utils.NoDefault |
|||
| ) |
| def webtest.forms.Form.lint | ( | self | ) |
| def webtest.forms.Form.select | ( | self, | |
| name, | |||
value = None, |
|||
text = None, |
|||
index = None |
|||
| ) |
| def webtest.forms.Form.select_multiple | ( | self, | |
| name, | |||
value = None, |
|||
texts = None, |
|||
index = None |
|||
| ) |
| def webtest.forms.Form.set | ( | self, | |
| name, | |||
| value, | |||
index = None |
|||
| ) |
| def webtest.forms.Form.submit | ( | self, | |
name = None, |
|||
index = None, |
|||
value = None, |
|||
| args | |||
| ) |
Submits the form. If ``name`` is given, then also select that button (using ``index`` or ``value`` to disambiguate)``. Any extra keyword arguments are passed to the :meth:`webtest.TestResponse.get` or :meth:`webtest.TestResponse.post` method. Returns a :class:`webtest.TestResponse` object.
| def webtest.forms.Form.submit_fields | ( | self, | |
name = None, |
|||
index = None, |
|||
submit_value = None |
|||
| ) |
| def webtest.forms.Form.upload_fields | ( | self | ) |
tuple webtest::forms.Form::_label_re [static, private] |
tuple webtest::forms.Form::_tag_re = re.compile(r'<(/?)([a-z0-9_\-]*)([^>]*?)>', re.I) [static, private] |
webtest::forms.Form::FieldClass = Field [static] |