Selenium Tutorial: Test Cases And Test Suites

4. Test-Cases and Test-Suites

4.1. Selenese

  • Selenium IDE produces tests that are written in a DSL (Domain Specific Language) called Selenese.
  • Selenese tests are simple xHTML tables of 3 columns and as many rows that there are steps in your test.

    The rule for these commands is:

    • A method on the first column: the action to perform
    • A locator on the second column: the subject of the method (ie: what element is acted upon)
    • A value on the third one: the value to be passed to the method (what to type in a text field for instance)

      Table 1. Selenese test-case

      Pizza Test


      / (1)


      q (2)


      click (3)


      assertTextPresent (4)


      1. The subject of the command open: the root of the application here
      2. q is the locator referring to the text field in which type will write pizza
      3. click doesn’t need a second argument, we just click on an element (which locator is btnG)
      4. assertTextPresent doesn’t need a locator since it searches on the entire page: we just need what to look for

And the corresponding source below - usually you don’t have to touch it, Selenium IDE will do it for you:

Selenese test-case source. 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="en" lang="en"> 1

<head profile=""> 2
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <link rel="selenium.base" href="" />
  <title>Pizza Test</title> 3
  <table cellpadding="1" cellspacing="1" border="1"> 4
     <tr><td rowspan="1" colspan="3">Pizza Test</td></tr>
      <tr> 5
        <td>open</td> 6
        <td>/</td> 7
        <td>pizza</td> 8


XML declaration, DTD and xHTML namespace


The profile attribute specifies this is a test-case


The html <title> tag corresponds to the test title


The test case in itself is enclosed in an HTML table


Each row of the table corresponds to a step in the test


The first cell of the row contains the command to execute, it is mandatory


The second cell is the target of the command (a locator). Here, open targets /, the root of the webapp


The third cell is the value that may be used by a command. Here, the command type is instructed to type pizza in the element located by the name q.

The url of the website to be tested is not specified. It is up to the Selenium engine to run the test against a specific ‘base url’ that you provide for testing on different servers.

4.2. Test Suites

You can assemble test-cases into a test-suite

  • They are also expressed as HTML files
  • The test-suite only references test-case files as anchor elements
  • The anchors are nested inside a table of 1 column and as many rows as there are test-cases in the test-suite

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
    <html xmlns="" xml:lang="en" lang="en">
      <meta content="text/html; charset=UTF-8" http-equiv="content-type" />
      <title>Test Suite</title> 1
      <table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"> 2
          <tr><td><b>Test Suite</b></td></tr>
          <tr><td><a href="pizza.html">pizza</a></td></tr> 3
          <tr><td><a href="selenium-search.html">selenium-search</a></td></tr>


    The title of the test-suite is specified here


    As a test-case, the test-suite is also enclosed within an HTML table


    Each test of the test suite is a relative link to the test-case file

Copyright © 2021 ProTech Professional Technical Services, Inc. All Rights Reserved.

Sign In Create Account


Social Media