[TIP] What strategies to you use to factor seleniums tests to avoid duplications of the same or similar test steps?

adam goucher adam_goucher at hotmail.com
Wed Feb 13 18:48:58 PST 2008

First off, I would avoid selenese tests and go straight to selenium rc. You 
get the ability to control a browser and the power of a real language to 
drive and support it, etc.

So my pattern for tests is the following...
- using the firefox ide extension, record the basics of the test
- output it to python
- copy and paste into python and use its unittest module
- add additional logic for reporting, data driving, etc

As for dealing with the duplicate code issue, I have addressed this in two 
different way
- selenese: http://adam.goucher.ca/?p=207
- python: use standard object-oriented pattern of encapsulating common code 
in a parent class (though I did have to patch jython's unittest module to 
make it work)

I've got a number of posts on selenium on my site (but don't trust the 
'selenium' category, use search instead).


From: "Bob Clancy" <bob.clancy at verizon.net>
Sent: Wednesday, February 13, 2008 8:13 PM
To: <testing-in-python at lists.idyll.org>
Subject: [TIP] What strategies to you use to factor seleniums tests to avoid 
duplications of the same or similar test steps?

>    I'm coming up to speed on Selenium becase I think it may be useful in
> upcoming jobs.  Two interesting areas of reading so far have been:
>    http://www.slideshare.net/dampy/selenium-204802
>    http://safari.oreilly.com/9780596527808
> The second of these is an OReilly "ShortCut" book (about 60 pages) that 
> gets
> you started with the basics on testing with twill and Selenium.  The first
> link above is a slide-show that offers some deeper insights about where 's
> strengths and weaknesses are.  After following along with the OReilly
> exercises, and rereading the slide-show, it doesn't look like it will be
> easy to avoid "duplicated test logic" in Selenium. This makes me want to 
> use
> another framework where I can structure action words to do higher level
> actions needed in testing.  I want something like the way that Mercury
> QuickTest Pro allows you to call other actions from within an existing
> action.  I've used that approach in QTP and it worked well for me.
>    I'd like to hear of others have experience in factoring out "duplicate
> functionality" from Selenium or whether you just use Selenium lightly 
> (only
> for client-javascript and cross-browser testing).  One idea that comes to
> mind is to use Selenium from another language and call into Selenium tests
> from FIT instead of using Selenium's test runner.  Another idea is to 
> write
> lots of selenium "Domain Specific Actions" that do basic higher-level
> application-specific operations (such as logging in or out of an
> application) that would otherwise be repeated very often as duplicate 
> code.
> This might be more work that it's worth in Selenium, so using another
> framework more suited to domain specific keywords seems more natural to 
> me.
> Another such framework could be twill.  You could develop "DSL" keywords 
> in
> twill that call out to recorded tests where needed, and do the http-only
> server tests where they are needed.
>    Also I'm interested in knowing if anyone has strategies for grabbing 
> the
> http calls produced by the client that are sent to the server.   I've used
> JMeter as a proxy recorder in the past, but it would be nice to have an
> integrated tool that does action words at the high level, does javascript
> testing in the slower browser based mode, but records and optimizes the 
> http
> calls and automatically associates them to tests so you can first record 
> in
> the browser, and then optimize some of this out to http requests to test 
> the
> server.
>    I hope I'm making sense in what I'm trying to say.  Basically I want 
> the
> best of all worlds where possible, and I'm interested in learning what
> strategies you use to accomplish goals similar to the ones that I have
> stated above.
> thanks,
> --
> Bob Clancy  (9 Lives Software Engineering,  Boston, MA, USA)
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

More information about the testing-in-python mailing list