[twill] using extend_with modules in python script?

Titus Brown titus at caltech.edu
Mon Jun 26 15:02:24 PDT 2006


On Mon, Jun 26, 2006 at 02:28:38PM -0700, Michael wrote:
-> Hi,
-> 
-> I'm new to twill. It's really cool.
-> 
-> I was wondering if something like this could be added (or maybe it's already
-> there?):
-> 
-> #extendtwill.py
->     from twill import commands
->     def find_link(regex):
->         link = commands.get_browser().find_link(regex)
->         return link
-> 
-> 
-> #twilltest.py:
->     import twill
->     import re
->     twill.commands.extend_with('extendtwill')
->     # [code to get some web page...]
->     twill.commands.find_link(re.compile('foo')) # ERROR!
-> 
-> Where extend_with() would make extension functions (like find_link())
-> available in the twill.commands namespace.

Hi, Mike,

you can just do:

import extendtwill
extendtwill.find_link(regexp)

right?

Is there a reason you want it specifically in the twill.commands
namespace?

cheers,
--titus



More information about the twill mailing list