About

Welcome to Panela, Matt Harrison's take on mostly Open Source, Linux, Python, innovation in those areas, other buzzwords and Dick Proenneke. It comes complete with the illustrations as needed. Note the opinions expressed here are merely my opinions and not the opinions of my employer.

about Matt

Calendar

««May 2008»»
SMTWTFS
     123
45678910
11121314151617
18192021222324
25262728293031

My Top Tags

                                       

Mailing List

My RSS Feeds








Generate twill scripts and mechanize unittests from TestGen4Web

posted 2005.12.05 Mon

UPDATE (Jan 2007)Duncan McGregor has taken these scripts and run with them. There is an updated version on the cheeseshop! Thanks Duncan. (Behold open source!) end update

While attending FOSS.IN, one of the sessions was a website security session.  I only caught the tail end, but it felt very similar to a session at OSCON this year by Nitesh.  I also attended part of Rasmus' talk where he talked about a tool he uses for detecting XSS.  Which in turn motivated (reminded) me to examine some of the python tools for programming and simulating web browsers.  I checked out both Mechanize and Twill by writing scripts that convert TestGen4Web output to a python unittest and twill script respectively.

Both twill and mechanize seem to work pretty well and appear to be actively developed.  I had some issues with twill saying "& was unepected at this time" (still haven't resolved that, though repeating the command doesn't cause a repeat of the error...) while running scripts.  Twill appears to nicely ignore robots.txt (and possibly update the user agent?), whereas I needed to explicitly tell mechanize to both ignore robots.txt (as well as change the user agent to impersonate moz).  That  behavior seems reasonable since twill is meant to be interactive.

One area where both are (understandably) lacking is javascript support.  With ajax becoming more popular and widespread, this functionality is likely needed.  Though this is probably a case where a pure python solution would seem silly.  Python wrappers to the moz object model seem the way to go (don't know if that's possible though).

tags:                  

links: digg this    del.icio.us    reddit




1. titus left...
2005.12.05 Mon 11:37 pm :: http://www.advogato.org/person/titus/

the "& was unexpected" sounds like a pyparsing error; let me know if you run across it again.


2. S. Fermigier left...
2005.12.06 Tue 2:16 am :: http://www.nuxeo.com/

Have you tried looking at FunkLoad (Mechanize-based, xUnit-inspired, functional and load testing framework) ?


3. Matt left...
2005.12.06 Tue 3:10 am

Oh, you gotta love open source. When the first person to respond is the author of the program ;) I'll be working with the Twill folks to figure that out.

S. Fermigier- Yes, I've heard of FunkLoad. I had also heard through the grapevine that one of the devs was going to write a translator for tg4w, hence I haven't done much on the FunkLoad front. They can take a look at the code I've posted and build ontop of the parser and handler provided. (And fix bugs add features ;))


4. Benji York left...
2005.12.06 Tue 10:36 am :: http://benjiyork.com

You might be interested in zope.testbrowser. It's used for Zope 3 functional tests and is also usable outside of Zope. http://cheeseshop.python.org/pypi?:action=display&name=zope.testbrowser


5. Matt left...
2005.12.06 Tue 9:19 pm

Benji- Thanks for the link. Are you familiar with mechanize? Any salient thoughts on why one would use testbrowser instead?


6. titus left...
2005.12.07 Wed 12:21 pm :: http://www.advogato.org/person/titus/

zope.testbrowser is based on mechanize, as is twill.

mechanize (and mechanoid, a fork of mechanize) are more of a Web browsing toolkit than fully functional Web browsers in their own right. zope.testbrowser and twill enable specific mechanize functionality and layer a simpler interfac on top of the basic mechanize behavior.

it is *very* difficult to write a fully-functional Web browser, which is what John J. Lee has done with mechanize ;).


7. titus left...
2005.12.07 Wed 12:24 pm :: http://www.advogato.org/person/titus/

oh, and funkload is *not* based on mechanize, it's based on webunit... also a good (but less feature-full) Python browsing package.


8. Kevin left...
2005.12.09 Fri 12:05 pm :: http://keturn.net/

For the browser-intergated tests, check out Selenium. It's not written in Python but can be driven from it.


9. Pierre Cros left...
2006.01.05 Thu 2:23 am :: http://www.entrouvert.com

Hi,

I work for Entr'ouvert a Free Software Company.

I'm really interrested in your tg4wTwill.py script as I would like to use TestGen4Web and Twill to test our web applications.

I can't find any place where to dowload it. Any clue ?

Thanks very much

Pierre


10. Titus Brown left...
2006.02.16 Thu 11:43 am

Hey Matt,

I figured out the '& is unexpected' error; it will be fixed in the next release. For the moment, ust turn 'do_run_tidy' off in the config options if you want to stop it from showing up ;).