splinter icon indicating copy to clipboard operation
splinter copied to clipboard

What is the proper way to submit a form? (DjangoClient)

Open drernie opened this issue 8 years ago • 4 comments

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?

drernie avatar Feb 27 '16 23:02 drernie

My initial hypothesis is that:

  • Button should be a DjangoClientControlElement
  • The 'submit' method should use 'getitem' instead of 'attire' for accessing form info.

drernie avatar Feb 27 '16 23:02 drernie

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]?

drernie avatar Feb 27 '16 23:02 drernie

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?

drernie avatar Feb 27 '16 23:02 drernie

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.

drernie avatar Feb 29 '16 21:02 drernie