[twill] twill browser object and form values
James Cameron
james.cameron at hp.com
Sun Mar 22 16:40:25 PDT 2009
On Sat, Mar 21, 2009 at 08:02:53AM -0700, C. Titus Brown wrote:
> To implement your suggestion, I'd want to add another layer between
> commands.py and browser.py that didn't deal with low level decision
> making (like the current browser) but was also not singleton-attached
> like the commands.py functions. Does this add to the complexity of
> twill in a bad way?
Yes.
Instead, move the browser specific part of fv to be a convenience
function of browser.py, that's all. The commands.py implementation
would become more simple.
> I've thought about doing what you suggested before, but always rejected
> it on intuition as being too enterprise-y. Maybe it's time to
> revisit... any other thoughts?
I hit the same snag, I may have posted about it, but what I ended up
doing is borrowing the commands.py code and placing it within my
application, thus;
def formvalue(browser, formname, fieldname, value):
""" borrowed from twill """
import ClientForm
import twill.utils
from twill.errors import TwillAssertionError
from twill.utils import set_form_control_value
form = browser.get_form(formname)
if not form:
raise TwillAssertionError("no matching forms!")
control = browser.get_form_field(form, fieldname)
browser.clicked(form, control)
set_form_control_value(control, value)
Most of the rest of formvalue() in commands.py is just being helpful,
that can stay at commands.py level.
Or, put this logic in formvalue in twill.utils, near
set_form_control_value.
--
James Cameron
http://ftp.hp.com.au/sigs/jc/
More information about the twill
mailing list