Introduction to Functional Web Testing With Twill & Selenium

Part 2 :: Selenium IDE :: Record and Playback Tests

Synopsis

The Selenium IDE, although it does record and playback tests, is a complete integrated development environment and contains the entire Selenium Core. Recording and playback is fairly simple, and the extension also includes autocomplete of common Selenium commands, test debugging utilities, and options to save the tests as python scripts.

Selenium IDE
[Minutes 136 - 141]

Selenium IDE
 

Once you've started up the IDE (remember, select 'Selenium IDE' from the 'Tools' menu), let's try loading up our sample site and making a base assertion in the code. The steps for this are simple:

  1. You probably want to open a new window to record your test; otherwise Selenium will record you going between these instructions and the test you're trying to write.
  2. Start the Selenium IDE. You don't need to tell it to record; it should be doing that automatically. If it's not, though, click the big red button. The red button will be, um, more red if it's not recording. It's kind of shiny when it is recording.
  3. Set the Base URL to 127.0.0.1
  4. Type in 'http://127.0.0.1' in the location bar of your browser.
  5. Highlight the word 'Welcome' and right click
  6. Select the 'verifyTextPresent Welcome' element
  7. Stop recording
  8. Save the test case as 'sel_ide_basic.html'
  9. Selenium IDE

Okay, so now we have a test. Try playing it back through the IDE.

One thing to note is that you don't have to save the test as html -- you can save it as python. It'll export your test into a unittest-style python test that might do you some good when you're prototyping. Also, under the 'options' menu, you can click 'format' and then select 'python,' and it will show you the python source without you having to save it. It should give you a good idea of what selenium is doing and how you might script it.

 

on to selenium & python

Fluid 960 Grid System, created by Stephen Bau, based on the 960 Grid System by Nathan Smith. Released under the GPL/ MIT Licenses.