splinter icon indicating copy to clipboard operation
splinter copied to clipboard

refactor form methods

Open andrewsmedina opened this issue 14 years ago • 7 comments

splinter have finders by name, id, css_select, tag and xpath. But check, fill_in, choose get elements by name:

browser.choose("some-radio")

It's need change this, moving these methods from browser class to element class:

checkbox = find_by_name('my-checkbox')
checkbox.check()

andrewsmedina avatar Oct 01 '10 04:10 andrewsmedina

I'll start to work on this. Should we maintain backwards compatibility?

douglascamata avatar Aug 01 '11 22:08 douglascamata

how this would break the compatibility?

andrewsmedina avatar Aug 02 '11 02:08 andrewsmedina

I mean, remove the old methods from the browser's class.

douglascamata avatar Aug 02 '11 02:08 douglascamata

Dont need remove browser methods for that. Just add a equivalent in element class.

andrewsmedina avatar Aug 02 '11 02:08 andrewsmedina

It's a quite trick to add choose method to zope.testbrowser, since even if I query for a specific radio button by its ID, zope.testbrowser returns the group. e.g.:

<input type="radio" name="gender" value="m" id="gender-m" />
<input type="radio" name="gender" value="f" id="gender-f" />

If I query for the element with the ID gender-m, zope.testbrowser returns a ListControl representing the button group, and WebDriver returns the input itself. So, for the zope.testbrowser I'd need something like this:

element = browser.find_by_id('gender-m')
element.choose("M")

Look that it's verbose, but necessary, since zope.testbrowser doesn't know the input value. Now, with the WebDriver, I could write the following:

element = browser.find_by_id('gender-m')
element.choose()

Which makes a lot of sense. What should we do? Don't add support to choose methods on zope.testbrowser elements? Or use choose(value) for both?

fsouza avatar Oct 09 '11 16:10 fsouza

@fsouza I agree to use choose(value), but for what I understood, since the WebDriver returns a specific radio button, this value wouldn't matter, right ? only for the zope.testbrowser

bernardobarreto avatar May 07 '12 02:05 bernardobarreto

I think this ticket could be more extensive: not only form methods are missing in the WebDriverElement: some search methods like is_text_present and is_element_present_by_something would be useful additions.

I my opinion, this issue is also correlated with the #162 that proposes a refactor of the find_by_something methods.

How can I help?

michelts avatar Dec 03 '12 15:12 michelts

Closing, since #933 has deprecated the browser level functions. browser.find() uses name internally but this is configurable.

jsfehler avatar Feb 13 '24 18:02 jsfehler