splinter
splinter copied to clipboard
What is the proper way to submit a form? (DjangoClient)
Using the Django client, I can click on a link, but when I click on a button I get:
self = <splinter.driver.djangoclient.DjangoClientElement object at 0x112260890>
def click(self):
"""
Clicks in the element.
"""
> raise NotImplementedError
E NotImplementedError
with the element
elements <Element button at 0x11223d158>
outer_html <button class="w-button button" type="submit">
Sign Up
</button>
Am I missing something?
My initial hypothesis is that:
- Button should be a DjangoClientControlElement
- The 'submit' method should use 'getitem' instead of 'attire' for accessing form info.
Looking at: https://github.com/vijayanajay/projects/blob/master/opinionanalysis/Lib/site-packages/splinter/driver/djangoclient.py -- is that what is installed with pip install splinter[django]
?
Okay, I managed to get it to work by calling 'submit' using the form's element:
signup_form = browser.find_by_tag("form").first
result = browser.submit(signup_form._element)
But, I don't see the 'submit' method in the documentation; that claims we can submit forms using the 'click link':
http://splinter.readthedocs.org/en/latest/elements-in-the-page.html?highlight=submit
You can click in buttons. Splinter follows any redirects, and submits forms associated with buttons.
Which is the proper idiom to use?
Ignore deleted comments. The submission is working properly, but there still seems to be a bug where buttons aren't clickable. May file a new bug about that some other time.