Skip to content

Commit 625bca4

Browse files
committed
support HTML5 form attribute
By searching for input elements also outside the form tag itself, which belong to this form according to their `form` attribute. closes #8
1 parent 599371f commit 625bca4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

webtest/forms.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,14 @@ def _parse_fields(self):
432432
fields = OrderedDict()
433433
field_order = []
434434
tags = ('input', 'select', 'textarea', 'button')
435-
for pos, node in enumerate(self.html.find_all(tags)):
435+
elements = self.html.find_all(tags)
436+
if self.response:
437+
elements.extend(
438+
elt for elt in self.response.html.find_all(
439+
tags, attrs={'form': self.id})
440+
if elt not in elements
441+
)
442+
for pos, node in enumerate(elements):
436443
attrs = dict(node.attrs)
437444
tag = node.name
438445
name = None

0 commit comments

Comments
 (0)