splinter
splinter copied to clipboard
refactor form methods
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()
I'll start to work on this. Should we maintain backwards compatibility?
how this would break the compatibility?
I mean, remove the old methods from the browser's class.
Dont need remove browser methods for that. Just add a equivalent in element class.
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 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
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?
Closing, since #933 has deprecated the browser level functions. browser.find() uses name internally but this is configurable.