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

Exposes "submit" method on form elements #107

Open
turicas opened this issue Oct 9, 2011 · 5 comments
Open

Exposes "submit" method on form elements #107

turicas opened this issue Oct 9, 2011 · 5 comments

Comments

@turicas
Copy link
Contributor

turicas commented Oct 9, 2011

If I have a form, like in:

from splinter.browser import Browser
browser = Browser()
browser.visit('http://www.google.com/')
my_form = browser.find_by_tag('form').first

the object my_form._element will have the submit method.

As we should not use _element since it is related to Selenium, Splinter should exposes a submit method in this form-object, so we can submit forms without needing to search for the submit button (or element that actually submits the form).

It is not useful when we want to test if some button, when clicked, submits the form correctly. But it's very useful when we just want to submit the form and check what is the response (and don't want to know the name of the button/element that submits the form).

@fsouza
Copy link
Contributor

fsouza commented Oct 9, 2011

Indeed we can provide a FormElement class and use with to provide a nice syntax:

with browser.get_form_by_id('my_form') as form:
    form.fill('name', 'Bla')
    form.fill('age', '20')
    form.submit() 

It's a bit related to issue #28.

@turicas
Copy link
Contributor Author

turicas commented Oct 9, 2011

I think we should return FormElement when we do a search (with browser.find_*) and the result is a form tag. It should work with all browsers available and be a Splinter's abstraction (not specific to any browser driver).

The context manager you propose is just syntactic sugar around this idea -- first we need to return objects which have methods and attributes that makes sense (so I think #111 is more important than #28).

This issue is strongly related to #111 (Return tag-specific objects in DriverAPI.find_* methods) -- really, issue #111 is a generalisation of this (for all kind of HTML elements).

@turicas turicas closed this as completed Oct 9, 2011
@turicas turicas reopened this Oct 9, 2011
@turicas
Copy link
Contributor Author

turicas commented Oct 9, 2011

Sorry, I wrongly cliked "comment & close".

@objarni
Copy link

objarni commented Sep 19, 2015

Has this been adressed? I would like to be able to choose which submit button to use in case there are several.

@drernie
Copy link

drernie commented Feb 29, 2016

+1 Seems related to my problems with #471.

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

4 participants