Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 5 down vote accepted

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.

share|improve this answer
+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! – SingleNegationElimination Oct 11 '11 at 15:50
+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. – Ethel Evans Oct 11 '11 at 21:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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