- 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
open
/
(1)type
q
(2)pizza
click
(3)btnG
assertTextPresent
(4)glob:*pizza*
-
The subject of the command
open
: the root of the application here -
q
is the locator referring to the text field in whichtype
will writepizza
-
click
doesn’t need a second argument, we just click on an element (which locator isbtnG
) -
assertTextPresent
doesn’t need a locator since it searches on the entire page: we just need what to look for
-
The subject of the command
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="selenium.base" href="" /> <title>Pizza Test</title>
</head> <body> <table cellpadding="1" cellspacing="1" border="1">
<thead> <tr><td rowspan="1" colspan="3">Pizza Test</td></tr> </thead> <tbody> <tr>
<td>open</td>
<td>/</td>
<td></td> </tr> <tr> <td>type</td> <td>q</td> <td>pizza</td>
</tr> <tr> <td>click</td> <td>btnG</td> <td></td> </tr> <tr> <td>assertTextPresent</td> <td></td> <td>regexp:*pizza*</td> </tr> </tbody> </table> </body> </html>
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 .
|
![]() | Note |
---|---|
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. |
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta content="text/html; charset=UTF-8" http-equiv="content-type" /> <title>Test Suite</title>
</head> <body> <table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium">
<tbody> <tr><td><b>Test Suite</b></td></tr> <tr><td><a href="pizza.html">pizza</a></td></tr>
<tr><td><a href="selenium-search.html">selenium-search</a></td></tr> </tbody> </table> </body> </html>