The advantage I see to selenium is that it in combination with the
functionality tests are a whole lot faster to write, than the
I click on record in the selenium ide, interact with my app to test a
specific feature (or sequence). When I want to assert a specific element
is present (or not) I use the xpath checker to get a specific handle to
the dom element.
At the end of the session, my functional test is ready for me and I’ve
done very little typing (just a few clicks). I can now modify it if
I’d start by generating the test with script/generate selenium
test_name, open that test in the ide and click away.
The way I see it, testing the controller mostly involves testable
changes in the UI. Testing the business logic usually occurs in the unit
tests for me. I use the functional testing to make sure the UI is
responding the way I expect it to, so why use the traditional functional
tests for that when you can use selenium.
I can imagine testing things like action mailer with the traditional
functional tests but little more.
I imagine Selenium to be like my end user, beta testing my app.
or am I missing something?
Jonathan V. wrote:
I was thinking about that same question recently.
I decided to slim down my functional tests to only test the logic of the
controller. If an action is supposed to update/save/add records, I will
have a functional test to ensure that the action works correctly, and
that records are saved/updated in the database. A Selenium test will
check that the correct parts of the page are updated and/or the user is
Basic idea: no assert_tag calls in functional tests! Only test the
business logic of each action.
BTW: I have got my own Selenium testing plugin, which lets you write
Selenium tests in the same way you write functional/unit tests. It’s a
bit rough, but check out
http://blog.viney.net.nz/articles/2006/02/09/selenium-testing if you’re
interested. You end up writing tests like:
class PersonSeleniumTest < Test::Unit::TestCase
fixtures :people, :notes
p = people(:bob)
p.notes.each do |note|
I like this approach because it gives a consistent way of writing tests,
the plugin definitely needs tidying up though.