Since the start of this thread, I've only just looked into using
Selenium RC and how to integrate that with web2py. I haven't come up
with a "good" solution yet, but I'll keep you posted.
How does selenium compare with other products? I haven't used
anything else, but a cursory look at the two mentioned, shows Selenium
as being more flexible/powerful than twill and more cross-browser than
TestGen4Web.
How I use selenium now is I've downloaded selenium core and put it in
my static files (it's just a few webpages and lots of javascript). I
have a test script that runs through all possible combinations of how
logging into my website should behave.
How has selenium helped my web dev? Easy question, it speeds up
testing by magnitudes and makes testing less boring and more
thorough. Also it gives you a CYA factor for when someone says
something doesn't work right. All you have to do is show them the
test. If you haven't tested a particular aspect of something, it will
become apparent rather quickly. The solution is to add that
particular regression to your test script and in no time, you'll have
an extensive battery of tests for your webapp.
Web app testers such as Selenium do not only test the View...however,
it is through the view that they do their testing. In a true MVC
model, the Controller is the only thing that can be tested since it is
the only place where logic should exist in the process. However, most
developers have views that show things differently based on different
input from the controller. So we have logic in our views as well. It
goes without saying that certain behaviors in the controller produce
certain manifestations in the corresponding view. For example, in my
login application, if the user enters an incorrect password, it
returns with a flash-message based on how it is incorrect (illegal
characters, no password supplied, etc.). This flash is testable (via
Selenium or others) and it is testing both the view logic and the
controller logic. Hence, we can use Selenium to test both the
controller and the view. Models don't possess logic in themselves
(unless you want to test constraints but that's silly).
Selenium core can only run javascript and manipulate a browser. For
that reason, it cannot set application state without you providing a
web-facing front-end to facilitate that (if you do, be wary of
security concerns). Selenium RC, can run as a normal Python unittest
and could therefore manipulate application state when run from the
web2py shell as Massimo pointed out. I'm going to look more into this
on Monday.
@yarko:
The Selenium RC server is the only portion written in Java and that is
only necessary for tests written in languages other than HTML
Selenese. You could make tests via the IDE and run them purely with
Selenium core without having to mess with Java at all. Actually, I'd
like to find a way to cleanly start/stop Selenium RC Server from
web2py for good integrated testing. I'll let you know. But if you
want to get started with it, download Selenium Core and the IDE and
get going.
=)