I have been doing some browser automation testing recently using Selenium (and Watin a bit too) and have reached a point where I am looking for recommendations on controlling the environment I'm testing.

For example, if I have a test that registers a new user on site (or similar database dependent task); how do people ensure that the test does not persist or at least is able to be repeated without always changing the test itself?

I'm seeking recommendations for ensuring my integration/acceptance tests using Selenium can be ran without having to worry about changing them or the environment manually.

1 Answer 1


Run Selenium from a separate programming language's testing framework.

Guaranteeing the evironment is OK without manually doing any work is really hard to do if you're using the selenium recorder and playing back in their standard test language. You'll need to export the code from the testrunner (or write it yourself) using a language like Java or C# where you have full access to Selenium and the Selenium Grid within the context of unit testing frameworks like NUnit and JUnit.

These testing frameworks using the flow of: Setup -> Test -> Tear Down.

This gives you the opportunity before the web test is run to add an item to the database so that your Selenium test, which runs directly after, will be guaranteed to have something to delete. Similarly, the Tear Down could then delete the new user that you create. The testing frameworks give you more power and access to be able to script things you definitely have to do running Selenium from the Selenium recorder/runner.

  • +1: selenese is great for figuring out for what a test should look like, but pretty lousy for actually doing testing. You can export selenese tests into a skeleton many languages! Oct 11, 2011 at 15:50
  • 1
    +1, but wanted to add - look up Page Objects while you are at it! I've saved a ton of maintenance time by writing page objects to use in automated tests. Oct 11, 2011 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.