summaryrefslogtreecommitdiff
path: root/tests/FunctionalTests/selenium/doc/testrunner.html
blob: 86cac0cb207d59c87ded42012e165e551969010b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.5: http://docutils.sourceforge.net/" />
<title>TestRunner Reference</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<body>
<h1 class="title">TestRunner Reference</h1>
<div class="document" id="testrunner-reference">
<div class="section" id="test-suites">
<h1><a name="test-suites">Test Suites</a></h1>
<blockquote>
<p>A test suite is represented by an HTML document containing a single-column table.  Each entry in the table should be a hyperlink to a test-case document.  The first row will be ignored by Selenium, so this can be used for a title, and is typically used to hold a title.</p>
<p>By default Selenium will attempt to load the test-suite from &quot;tests/TestSuite.html&quot;.  An alternative test-suite source can be specified by appending a &quot;test&quot; parameter to the TestRunner.html URL, e.g.:</p>
<pre class="literal-block">
http://localhost:8000/TestRunner.html?test=AllTests.php
</pre>
<p>The &quot;test&quot; URL is interpreted relative to the location of TestRunner.html.</p>
</blockquote>
</div>
<div class="section" id="test-cases">
<h1><a name="test-cases">Test Cases</a></h1>
<blockquote>
<p>A test-case is represented by an HTML document, containing a table with 3 columns: <em>command</em>, <em>target</em>, <em>value</em>.  Not all commands take a value, however.  In this case either leave the column blank or use a &amp;nbsp; to make the table look better.</p>
<p>The first row will be ignored by Selenium, so this can be used for a title or any other information.</p>
<p>Example:</p>
<blockquote>
<table border="1" class="table">
<colgroup>
<col width="31%" />
<col width="38%" />
<col width="31%" />
</colgroup>
<tbody valign="top">
<tr><td colspan="3">Simple Test Table</td>
</tr>
<tr><td>open</td>
<td>/mypage</td>
<td>&nbsp;</td>
</tr>
<tr><td>type</td>
<td>nameField</td>
<td>John Smith</td>
</tr>
<tr><td>click</td>
<td>submitButton</td>
<td>True</td>
</tr>
<tr><td>verifyText</td>
<td>name</td>
<td>John Smith</td>
</tr>
</tbody>
</table>
</blockquote>
</blockquote>
</div>
<div class="section" id="setup-teardown">
<h1><a name="setup-teardown">SetUp / TearDown</a></h1>
<blockquote>
<p>There are no setUp and tearDown commands in Selenium, but there is a way to handle these common testing operations.  On the site being tested, create URLs for setUp and tearDown.  Then, when the test runner opens these URLs, the server can do whatever setUp or tearDown is necessary.</p>
<p>Example:</p>
<blockquote>
<p>For the T&amp;E project, we wanted the functional tests to run as a dummy user.  Therefore, we made a /setUpFT URL that would create a dummy user and write the userID to the page.  Then, we can store this value (using the command storeValue) and use it in the script.  Finally, we made a /tearDownFT URL which takes the dummy userID as a parameter and deletes the user.  Therefore, our tests look like this:</p>
<table border="1" class="table">
<colgroup>
<col width="21%" />
<col width="58%" />
<col width="21%" />
</colgroup>
<tbody valign="top">
<tr><td colspan="3">Setup and Teardown</td>
</tr>
<tr><td>open</td>
<td>/setUpFT</td>
<td>&nbsp;</td>
</tr>
<tr><td>storeValue</td>
<td>userid</td>
<td>&nbsp;</td>
</tr>
<tr><td>open</td>
<td>/login</td>
<td>&nbsp;</td>
</tr>
<tr><td>type</td>
<td>userID</td>
<td>${userid}</td>
</tr>
<tr><td>click</td>
<td>submit</td>
<td>&nbsp;</td>
</tr>
<tr><td>open</td>
<td>/tearDownFT?userid=${userid}</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</blockquote>
</blockquote>
</div>
<div class="section" id="continuous-integration">
<h1><a name="continuous-integration">Continuous Integration</a></h1>
<blockquote>
<p>Selenium can be integrated with an automated build.  When the parameter &quot;auto=true&quot; is added to the URL, Selenium will run the entire suite of tests, and then post the results to a handling URL.  The default URL is &quot;/postResults&quot;, but an alternative handler location can be provided by specifying a &quot;resultsUrl&quot; parameter.</p>
<p>The fields of the post are:</p>
<blockquote>
<table border="1" class="table">
<colgroup>
<col width="15%" />
<col width="85%" />
</colgroup>
<thead valign="bottom">
<tr><th>Parameter</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>result</td>
<td>the word &quot;passed&quot; or &quot;failed&quot; depending on whether the whole suite passed or at least one test failed.</td>
</tr>
<tr><td>totalTime</td>
<td>the time in seconds for the whole suite to run</td>
</tr>
<tr><td>numTestPasses</td>
<td>tht total number of tests which passed</td>
</tr>
<tr><td>numTestFailures</td>
<td>the total number of tests which failed.</td>
</tr>
<tr><td>numCommandPasses</td>
<td>the total number of commands which passed.</td>
</tr>
<tr><td>numCommandFailures</td>
<td>the total number of commands which failed.</td>
</tr>
<tr><td>numCommandErrors</td>
<td>the total number of commands which errored.</td>
</tr>
<tr><td>suite</td>
<td>the suite table, including the hidden column of test results</td>
</tr>
<tr><td>testTable.1</td>
<td>the first test table</td>
</tr>
<tr><td>testTable.2</td>
<td>the second test table</td>
</tr>
<tr><td>...</td>
<td>...</td>
</tr>
<tr><td>testTable.N</td>
<td>The Nth test table</td>
</tr>
</tbody>
</table>
</blockquote>
<dl>
<dt>Therefore, the steps for continuous integration are:</dt>
<dd><ol class="first last arabic">
<li><p class="first">Create a servlet-type application at the url /postResults which can read the parameters above and write them to a file</p>
</li>
<li><dl class="first">
<dt>Create a script which can start up a brower and send to to the URL: selenium?auto=true</dt>
<dd><ul class="first last">
<li><dl class="first">
<dt>Generally, this can be done by merely calling the browser with the URL as an argument:</dt>
<dd><p class="first last">firefox.exe <a class="reference" href="http://localhost/selenium?auto=true">http://localhost/selenium?auto=true</a></p>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first">
<dt>Make your continuous build:</dt>
<dd><ul class="first last simple">
<li>Call the script from step 2, preferably using more than one browser</li>
<li>Wait for it to finish, possibly by checking for the existence of the file(s) from step 1</li>
<li>Parse these files to determine whether the build passed or failed</li>
<li>Act accordingly (send emails, update a build web page, etc.)</li>
</ul>
</dd>
</dl>
</li>
</ol>
</dd>
</dl>
</blockquote>
<hr />
<table class="field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Authors:</th><td class="field-body">Paul Gross, Jason Huggins</td>
</tr>
<tr class="field"><th class="field-name">Created Date:</th><td class="field-body">08/23/2004</td>
</tr>
<tr class="field"><th class="field-name">Modified Date:</th><td class="field-body">28/01/2005</td>
</tr>
<tr class="field"><th class="field-name">Created With:</th><td class="field-body">reStructuredText: <a class="reference" href="http://docutils.sourceforge.net/rst.html">http://docutils.sourceforge.net/rst.html</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>