Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML5 form support #8

Open
domenkozar opened this issue Nov 13, 2012 · 4 comments
Open

HTML5 form support #8

domenkozar opened this issue Nov 13, 2012 · 4 comments

Comments

@domenkozar
Copy link
Member

Anonymous:

HTML5 adds a new attribute to input tags, named "form":
( see http://dev.w3.org/html5/spec/single-page.html#form-associated-element ).
If an input has a "form" attribute, webtest breaks when one
accesses response.forms:

TypeError: init() got multiple values for keyword argument 'form'

(this is on line 1563 of app.py in webtest 1.4.0)

The problem is actually on line 1206, which includes a positional arg called
'form'. An attribute named 'form' will now be passed in attrs, causing the
conflict.

def init(self, form, tag, name, pos, value=None, id=None, attrs):

Iwan Vosloo:

I guess supporting form-associated elements is actually a slightly bigger issue
than that conflicting kwarg... WebTest would have to make sure it collects all
the inputs of a particular form - including those that are associated with the
form but located elsewhere.

URL: https://bitbucket.org/ianb/webtest/issue/45/html5-form-associated-inputs-break-webtest

@gawel
Copy link
Member

gawel commented Feb 23, 2013

There is no library to do such things so we will wait until one appears. If we want to add that by ourself it will need to much code to maintain. We don't want that.

@wichert
Copy link
Member

wichert commented Sep 17, 2013

I"m not convinced any such library will appear by itself since this type of problem seems to be very specific to WebTest-like usage, so WebTest would be the logical source of such a library.

@IwanVosloo
Copy link

We've run into this again... and I had a quick look at the code of forms.Form._parse_fields. There's a line for pos, node in enumerate(self.html.findAll(tags)): which searches for elements that are ancestors of the Form, ie, the assumption is made that all form inputs will be descendants of the Form.

I gather that all webtest's elements are elements that originate from the response object passed to them. If that's the case, can't this issue be dealt with by simply doing a self.response.html.findAll(tags) and then ALSO filtering for tags that are either descendants of the form or have a form= attribute matching the Form's ID?

Somehow this does not seem like a huge stretch (provided I understand the code correctly)?

@septatrix
Copy link

A first step beside the form attribute would be to support formaction and formmethod when calling click on a button. This would already cover use cases like #175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants