-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathusing.html
More file actions
219 lines (187 loc) · 9.41 KB
/
using.html
File metadata and controls
219 lines (187 loc) · 9.41 KB
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
214
215
216
217
218
219
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Usage — Substeps documentation</title>
<link rel="stylesheet" href="_static/haiku.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/print.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/theme_extras.js"></script>
<link rel="top" title="Substeps documentation" href="index.html" />
<link rel="next" title="Getting started with Substeps" href="getting_started.html" />
<link rel="prev" title="Why?" href="why.html" />
</head>
<body>
<div class="header"><h1 class="heading"><a href="index.html">
<span>Substeps documentation</span></a></h1>
<h2 class="heading"><span>Usage</span></h2>
</div>
<div class="topnav">
<p>
«  <a href="why.html">Why?</a>
  ::  
<a class="uplink" href="index.html">Contents</a>
  ::  
<a href="getting_started.html">Getting started with Substeps</a>  »
</p>
</div>
<div class="content">
<div class="section" id="usage">
<h1>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h1>
<div class="section" id="simple-example">
<h2>Simple Example<a class="headerlink" href="#simple-example" title="Permalink to this headline">¶</a></h2>
<p>The example below illustrates the use of Substeps to test a web application, so for this particular case we would use the webdriver-substeps step defintitions.</p>
<div class="admonition">
<span style="color:#69BDCB;"># A comment</span><br/>
<span style="color:Green;">Tags:</span>phase1<br/><br/>
<span style="color:Red;">Feature:</span> A Feature to demonstrate Substeps<br/><br/>
<span style="color:Blue;">Scenario:</span> A simple high level scenario<br/>
<div style="position:relative;left:5em">
Given a user is logged in to the application<br/>
Then they can edit their profile<br/>
And post messages to their friends<br/>
</div>
</div></div>
<div class="section" id="an-example-substep-definitions-file">
<h2>An Example Substep definitions file<a class="headerlink" href="#an-example-substep-definitions-file" title="Permalink to this headline">¶</a></h2>
<div class="admonition">
<span style="color:#69BDCB;"># Substep definitions for ....</span><br/>
<span style="color:Blue;">Define:</span> Given a user is logged in to the application<br/>
<div style="position:relative;left:5em">
NavigateTo /index.html<br/>
ClickLink "Login"<br/>
WaitForPageTitle "Login in to your account"<br/>
ClearAndSendKeys "testuser1" to id login_id<br/>
ClearAndSendKeys "password" to id password_id<br/>
FindByTagAndAttributes tag="input" attributes=[type="submit",value="Login"]<br/>
WaitForPageTitle "your Profile"<br/>
</div>
<br/>
<span style="color:Blue;">Define:</span> Then they can edit their profile<br/>
<div style="position:relative;left:5em">
...<br/>
</div>
<br/>
<span style="color:Blue;">Define:</span> And post messages to their friends<br/>
<div style="position:relative;left:5em">
...<br/>
</div>
</div><ul class="simple">
<li>In the simple example above, you can see how steps within a scenario can be broken down into a series of Substeps.</li>
<li>The feature and scenario remain descriptive, whilst the substep definitions contain the details of how that particular step is implemented</li>
<li>Substep definitions can call each other, and other scenarios too.</li>
</ul>
</div>
<div class="section" id="a-complex-example">
<h2>A complex example<a class="headerlink" href="#a-complex-example" title="Permalink to this headline">¶</a></h2>
<p>A more elaborate example is illustrated below, again with a web application under test.
Additional step definition libraries and custom implementations can be used alongside to provide extra functionality.</p>
<div class="admonition">
<span style="color:Red;">Feature:</span> A more complex feature<br/><br/>
<span style="color:#69BDCB;"># Background steps are defined once per feature and executed before each scenario</span><br/>
<span style="color:Blue;">Background:</span> <br/>
<div style="position:relative;left:5em">
Given the new user doesn't exist <br/>
</div><br/>
<span style="color:Blue;">Scenario:</span> As an administrator I can 'do stuff'<br/>
<div style="position:relative;left:5em">
Given I can log in as "administrator"<br/>
Then I can create a new user<br/>
</div>
<br/>
<span style="color:#69BDCB;"># Outline scenarios are executed repeatedly, once for each row of the Examples table following the scenario.</span><br/>
<span style="color:#69BDCB;"># Variables from the table are substituted.</span><br/>
<span style="color:Blue;">Scenario Outline:</span> I can log in with different users<br/>
<div style="position:relative;left:5em">
Given I can log in as "<username>"<br/>
<span style="color:#69BDCB;position:relative;left:2em;"># at runtime, the username token will be replaced with a value from the table below</span><br/>
Then I am greeted by my "<name>"<br/>
And my role is displayed as "<role_name>"<br/>
</div>
<br/>
<span style="color:Blue;">Examples:</span><br/>
<div style="position:relative;left:5em; width:50%"><pre>
|username |name |role_name |
|admin |Andy Admin |Administrator |
|boss |Sue Super |Supervisor |
|user |Bob Smith |User |
</pre></div>
</div>
<div class="admonition">
<span style="color:#69BDCB;"># Substep definitions for a complex feature ....</span><br/>
<span style="color:Blue;">Define:</span> Given I can log in as "<user_name>"<br/>
<span style="color:#69BDCB;position:relative;left:2em;"># This substep is passed a parameter which we can refer to by its name, <user_name> in this case</span><br/>
<div style="position:relative;left:5em">
NavigateTo /index.html<br/>
ClickLink "Login"<br/>
WaitForPageTitle "Login in to your account"<br/>
ClearAndSendKeys "<user_name>" to id login_id<br/>
ClearAndSendKeys "password" to id password_id<br/>
FindByTagAndAttributes tag="input" attributes=[type="submit",value="Login"]<br/>
WaitForPageTitle "your Profile"<br/>
</div>
<br/>
<span style="color:Blue;">Define:</span> Then I am greeted by my "<name>"<br/>
<div style="position:relative;left:5em">
FindById welcome-div<br/>
AssertCurrentElement text contains "<name>"<br/>
</div>
<br/>
<span style="color:Blue;">Define:</span> Given the new user doesn't exist<br/>
<div style="position:relative;left:5em">
DeleteUserFromDB "Nev Newbie" <span style="color:#69BDCB;"># a custom step implementation for this project</span><br/>
...<br/>
</div>
<br/>
<span style="color:Blue;">Define:</span> And my role is displayed as "<role_name>"<br/>
<div style="position:relative;left:5em">
...<br/>
</div>
<br/>
<span style="color:Blue;">Define:</span> Then I can create users<br/>
<div style="position:relative;left:5em">
<span style="color:#69BDCB;"># substeps to actually create a user</span><br/>
...<br/>
</div>
</div><p>Substep definitions can also call other substeps, not just step implementations.</p>
<p>Implementing bespoke step implementations is straight forward too, see <a class="reference external" href="http://technophobia.github.com/substeps/extending.html#step-implementations">here</a> for more details</p>
<div class="highlight-java"><div class="highlight"><pre><span class="nd">@StepImplementations</span>
<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MyProjectStepImplementations</span> <span class="o">{</span>
<span class="nd">@Step</span><span class="o">(</span><span class="s">"DeleteUserFromDB \"([^\"]*)\"</span><span class="o">)</span>
<span class="kd">public</span> <span class="kt">void</span> <span class="nf">deleteUserFromDB</span><span class="o">(</span><span class="kd">final</span> <span class="n">String</span> <span class="n">name</span><span class="o">){</span>
<span class="c1">// get connection</span>
<span class="c1">// execute SQL</span>
<span class="o">...</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="bottomnav">
<p>
«  <a href="why.html">Why?</a>
  ::  
<a class="uplink" href="index.html">Contents</a>
  ::  
<a href="getting_started.html">Getting started with Substeps</a>  »
</p>
</div>
<div class="footer">
© Copyright 2012, Technophobia.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>