bauxite 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/Rakefile +69 -0
  4. data/bin/bauxite +27 -0
  5. data/doc/Bauxite/Action.html +1463 -0
  6. data/doc/Bauxite/ActionModule.html +342 -0
  7. data/doc/Bauxite/Context.html +1439 -0
  8. data/doc/Bauxite/Errors/AssertionError.html +107 -0
  9. data/doc/Bauxite/Errors/FileNotFoundError.html +107 -0
  10. data/doc/Bauxite/Errors.html +100 -0
  11. data/doc/Bauxite/Loggers/CompositeLogger.html +325 -0
  12. data/doc/Bauxite/Loggers/EchoLogger.html +164 -0
  13. data/doc/Bauxite/Loggers/FileLogger.html +215 -0
  14. data/doc/Bauxite/Loggers/NullLogger.html +334 -0
  15. data/doc/Bauxite/Loggers/TerminalLogger.html +586 -0
  16. data/doc/Bauxite/Loggers/XtermLogger.html +287 -0
  17. data/doc/Bauxite/Loggers.html +103 -0
  18. data/doc/Bauxite/Selector.html +422 -0
  19. data/doc/Bauxite/SelectorModule.html +283 -0
  20. data/doc/Bauxite.html +98 -0
  21. data/doc/created.rid +37 -0
  22. data/doc/fonts/Lato-Light.ttf +0 -0
  23. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  24. data/doc/fonts/Lato-Regular.ttf +0 -0
  25. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  26. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  27. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  28. data/doc/fonts.css +167 -0
  29. data/doc/images/add.png +0 -0
  30. data/doc/images/arrow_up.png +0 -0
  31. data/doc/images/brick.png +0 -0
  32. data/doc/images/brick_link.png +0 -0
  33. data/doc/images/bug.png +0 -0
  34. data/doc/images/bullet_black.png +0 -0
  35. data/doc/images/bullet_toggle_minus.png +0 -0
  36. data/doc/images/bullet_toggle_plus.png +0 -0
  37. data/doc/images/date.png +0 -0
  38. data/doc/images/delete.png +0 -0
  39. data/doc/images/find.png +0 -0
  40. data/doc/images/loadingAnimation.gif +0 -0
  41. data/doc/images/macFFBgHack.png +0 -0
  42. data/doc/images/package.png +0 -0
  43. data/doc/images/page_green.png +0 -0
  44. data/doc/images/page_white_text.png +0 -0
  45. data/doc/images/page_white_width.png +0 -0
  46. data/doc/images/plugin.png +0 -0
  47. data/doc/images/ruby.png +0 -0
  48. data/doc/images/tag_blue.png +0 -0
  49. data/doc/images/tag_green.png +0 -0
  50. data/doc/images/transparent.png +0 -0
  51. data/doc/images/wrench.png +0 -0
  52. data/doc/images/wrench_orange.png +0 -0
  53. data/doc/images/zoom.png +0 -0
  54. data/doc/index.html +111 -0
  55. data/doc/js/darkfish.js +140 -0
  56. data/doc/js/jquery.js +18 -0
  57. data/doc/js/navigation.js +142 -0
  58. data/doc/js/search.js +109 -0
  59. data/doc/js/search_index.js +1 -0
  60. data/doc/js/searcher.js +228 -0
  61. data/doc/rdoc.css +580 -0
  62. data/doc/table_of_contents.html +510 -0
  63. data/lib/bauxite/actions/alias.rb +51 -0
  64. data/lib/bauxite/actions/assert.rb +49 -0
  65. data/lib/bauxite/actions/assertv.rb +40 -0
  66. data/lib/bauxite/actions/break.rb +39 -0
  67. data/lib/bauxite/actions/click.rb +35 -0
  68. data/lib/bauxite/actions/debug.rb +99 -0
  69. data/lib/bauxite/actions/echo.rb +36 -0
  70. data/lib/bauxite/actions/exec.rb +46 -0
  71. data/lib/bauxite/actions/js.rb +41 -0
  72. data/lib/bauxite/actions/load.rb +49 -0
  73. data/lib/bauxite/actions/open.rb +34 -0
  74. data/lib/bauxite/actions/params.rb +40 -0
  75. data/lib/bauxite/actions/replace.rb +37 -0
  76. data/lib/bauxite/actions/reset.rb +37 -0
  77. data/lib/bauxite/actions/return.rb +62 -0
  78. data/lib/bauxite/actions/ruby.rb +58 -0
  79. data/lib/bauxite/actions/set.rb +39 -0
  80. data/lib/bauxite/actions/source.rb +44 -0
  81. data/lib/bauxite/actions/store.rb +38 -0
  82. data/lib/bauxite/actions/test.rb +61 -0
  83. data/lib/bauxite/actions/tryload.rb +79 -0
  84. data/lib/bauxite/actions/wait.rb +38 -0
  85. data/lib/bauxite/actions/write.rb +40 -0
  86. data/lib/bauxite/application.rb +150 -0
  87. data/lib/bauxite/core/Action.rb +205 -0
  88. data/lib/bauxite/core/Context.rb +575 -0
  89. data/lib/bauxite/core/Errors.rb +36 -0
  90. data/lib/bauxite/core/Logger.rb +86 -0
  91. data/lib/bauxite/core/Selector.rb +156 -0
  92. data/lib/bauxite/loggers/composite.rb +70 -0
  93. data/lib/bauxite/loggers/echo.rb +36 -0
  94. data/lib/bauxite/loggers/file.rb +45 -0
  95. data/lib/bauxite/loggers/terminal.rb +130 -0
  96. data/lib/bauxite/loggers/xterm.rb +79 -0
  97. data/lib/bauxite/selectors/attr.rb +39 -0
  98. data/lib/bauxite/selectors/default.rb +38 -0
  99. data/lib/bauxite/selectors/frame.rb +60 -0
  100. data/lib/bauxite.rb +29 -0
  101. data/test/alias.bxt +6 -0
  102. data/test/assertv.bxt +2 -0
  103. data/test/delay/page.html +5 -0
  104. data/test/delay.bxt +2 -0
  105. data/test/exec.bxt +6 -0
  106. data/test/format/page.html +7 -0
  107. data/test/format.bxt +17 -0
  108. data/test/frame/child_frame.html +7 -0
  109. data/test/frame/grandchild_frame.html +5 -0
  110. data/test/frame/page.html +5 -0
  111. data/test/frame.bxt +6 -0
  112. data/test/js.bxt +5 -0
  113. data/test/load/child.bxt +13 -0
  114. data/test/load.bxt +17 -0
  115. data/test/ruby/custom.rb +5 -0
  116. data/test/ruby.bxt +2 -0
  117. data/test/selectors/page.html +7 -0
  118. data/test/selectors.bxt +7 -0
  119. data/test/stdin.bxt +1 -0
  120. data/test/test/test1.bxt +2 -0
  121. data/test/test/test2.bxt +3 -0
  122. data/test/test/test3.bxt +2 -0
  123. data/test/test.bxt.manual +4 -0
  124. metadata +194 -0
@@ -0,0 +1,1463 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Bauxite::Action - RDoc Documentation</title>
8
+
9
+ <link href="../fonts.css" rel="stylesheet">
10
+ <link href="../rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "../";
14
+ </script>
15
+
16
+ <script src="../js/jquery.js"></script>
17
+ <script src="../js/navigation.js"></script>
18
+ <script src="../js/search_index.js"></script>
19
+ <script src="../js/search.js"></script>
20
+ <script src="../js/searcher.js"></script>
21
+ <script src="../js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../table_of_contents.html#pages">Pages</a>
34
+ <a href="../table_of_contents.html#classes">Classes</a>
35
+ <a href="../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+ <div id="sections-section" class="nav-section">
60
+ <h3>Sections</h3>
61
+
62
+ <ul class="link-list" role="directory">
63
+
64
+ <li><a href="#5Buntitled-5D"></a></li>
65
+
66
+ <li><a href="#Action+Methods">Action Methods</a></li>
67
+
68
+ </ul>
69
+ </div>
70
+
71
+ <div id="parent-class-section" class="nav-section">
72
+ <h3>Parent</h3>
73
+
74
+
75
+ <p class="link">Object
76
+
77
+ </div>
78
+
79
+ <div id="includes-section" class="nav-section">
80
+ <h3>Included Modules</h3>
81
+
82
+ <ul class="link-list">
83
+
84
+
85
+ <li><a class="include" href="ActionModule.html">Bauxite::ActionModule</a>
86
+
87
+
88
+ </ul>
89
+ </div>
90
+
91
+
92
+ <!-- Method Quickref -->
93
+ <div id="method-list-section" class="nav-section">
94
+ <h3>Methods</h3>
95
+
96
+ <ul class="link-list" role="directory">
97
+
98
+ <li ><a href="#method-i-alias_action">#alias_action</a>
99
+
100
+ <li ><a href="#method-i-assert">#assert</a>
101
+
102
+ <li ><a href="#method-i-assertv">#assertv</a>
103
+
104
+ <li ><a href="#method-i-break_action">#break_action</a>
105
+
106
+ <li ><a href="#method-i-click">#click</a>
107
+
108
+ <li ><a href="#method-i-debug">#debug</a>
109
+
110
+ <li ><a href="#method-i-echo">#echo</a>
111
+
112
+ <li ><a href="#method-i-exec">#exec</a>
113
+
114
+ <li ><a href="#method-i-js">#js</a>
115
+
116
+ <li ><a href="#method-i-load">#load</a>
117
+
118
+ <li ><a href="#method-i-open">#open</a>
119
+
120
+ <li ><a href="#method-i-params">#params</a>
121
+
122
+ <li ><a href="#method-i-replace">#replace</a>
123
+
124
+ <li ><a href="#method-i-reset">#reset</a>
125
+
126
+ <li ><a href="#method-i-return_action">#return_action</a>
127
+
128
+ <li ><a href="#method-i-ruby">#ruby</a>
129
+
130
+ <li ><a href="#method-i-set">#set</a>
131
+
132
+ <li ><a href="#method-i-source">#source</a>
133
+
134
+ <li ><a href="#method-i-store">#store</a>
135
+
136
+ <li ><a href="#method-i-test">#test</a>
137
+
138
+ <li ><a href="#method-i-tryload">#tryload</a>
139
+
140
+ <li ><a href="#method-i-wait">#wait</a>
141
+
142
+ <li ><a href="#method-i-write">#write</a>
143
+
144
+ </ul>
145
+ </div>
146
+
147
+ </div>
148
+ </nav>
149
+
150
+ <main role="main" aria-labelledby="class-Bauxite::Action">
151
+ <h1 id="class-Bauxite::Action" class="class">
152
+ class Bauxite::Action
153
+ </h1>
154
+
155
+ <section class="description">
156
+
157
+ <p>Test action class.</p>
158
+
159
+ <p>Test actions are basic test operations that can be combined to create a
160
+ test case.</p>
161
+
162
+ <p>Test actions are implemented as public methods of the <a
163
+ href="Action.html">Action</a> class.</p>
164
+
165
+ <p>Each test action is defined in a separate file in the &#39;actions/&#39;
166
+ directory. The name of the file must match the name of the action. Ideally,
167
+ these files should avoid adding public methods other than the action method
168
+ itself. Also, no <code>attr_accessors</code> should be added.</p>
169
+
170
+ <p><a href="Action.html">Action</a> methods can use the <code>ctx</code>
171
+ attribute to refer to the current test <a href="Context.html">Context</a>.</p>
172
+
173
+ <p>For example (new action template):</p>
174
+
175
+ <pre class="ruby"><span class="ruby-comment"># === actions/print_source.rb ======= #</span>
176
+ <span class="ruby-keyword">class</span> <span class="ruby-constant">Action</span>
177
+ <span class="ruby-comment"># :category: Action Methods</span>
178
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">print_source</span>
179
+ <span class="ruby-comment"># action code goes here, for example:</span>
180
+ <span class="ruby-identifier">puts</span> <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">page_source</span>.
181
+ <span class="ruby-identifier">end</span>
182
+ <span class="ruby-keyword">end</span>
183
+ <span class="ruby-comment"># === end actions/print_source.rb === #</span>
184
+
185
+ <span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&#39;print_source&#39;</span> <span class="ruby-comment"># =&gt; true</span>
186
+ </pre>
187
+
188
+ <p>To avoid name clashing with Ruby reserved words, the &#39;_action&#39;
189
+ suffix can be included in the action method name (this suffix will not be
190
+ considered part of the action name).</p>
191
+
192
+ <p>For example (_action suffix):</p>
193
+
194
+ <pre class="ruby"><span class="ruby-comment"># === actions/break.rb ======= #</span>
195
+ <span class="ruby-keyword">class</span> <span class="ruby-constant">Action</span>
196
+ <span class="ruby-comment"># :category: Action Methods</span>
197
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_action</span>
198
+ <span class="ruby-comment"># do something</span>
199
+ <span class="ruby-keyword">end</span>
200
+ <span class="ruby-keyword">end</span>
201
+ <span class="ruby-comment"># === end actions/break.rb === #</span>
202
+
203
+ <span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&#39;break&#39;</span> <span class="ruby-comment"># =&gt; true</span>
204
+ </pre>
205
+
206
+ <p>If the action requires additional attributes or private methods, the name
207
+ of the action should be used as a prefix to avoid name clashing with other
208
+ actions.</p>
209
+
210
+ <p>For example (private attributes and methods):</p>
211
+
212
+ <pre class="ruby"><span class="ruby-comment"># === actions/debug.rb ======= #</span>
213
+ <span class="ruby-keyword">class</span> <span class="ruby-constant">Action</span>
214
+ <span class="ruby-comment"># :category: Action Methods</span>
215
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">debug</span>
216
+ <span class="ruby-identifier">_debug_do_stuff</span>
217
+ <span class="ruby-keyword">end</span>
218
+ <span class="ruby-identifier">private</span>
219
+ <span class="ruby-identifier">@@debug_line</span> = <span class="ruby-value">0</span>
220
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">_debug_do_stuff</span>
221
+ <span class="ruby-identifier">@@debug_line</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
222
+ <span class="ruby-keyword">end</span>
223
+ <span class="ruby-keyword">end</span>
224
+ <span class="ruby-comment"># === end actions/debug.rb === #</span>
225
+
226
+ <span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&#39;debug&#39;</span> <span class="ruby-comment"># =&gt; true</span>
227
+ </pre>
228
+
229
+ <p><a href="Action.html">Action</a> methods support delayed execution of the
230
+ test action. Delayed execution is useful in cases where the action output
231
+ would break the standard logging interface.</p>
232
+
233
+ <p>Delayed execution is implemented by returning a lambda from the action
234
+ method.</p>
235
+
236
+ <p>For example (delayed execution):</p>
237
+
238
+ <pre class="ruby"><span class="ruby-comment"># === actions/break.rb ======= #</span>
239
+ <span class="ruby-keyword">class</span> <span class="ruby-constant">Action</span>
240
+ <span class="ruby-comment"># :category: Action Methods</span>
241
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_action</span>
242
+ <span class="ruby-identifier">lambda</span> { <span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">wait</span> }
243
+ <span class="ruby-keyword">end</span>
244
+ <span class="ruby-keyword">end</span>
245
+ <span class="ruby-comment"># === end actions/break.rb === #</span>
246
+
247
+ <span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">actions</span>.<span class="ruby-identifier">include?</span> <span class="ruby-string">&#39;debug&#39;</span> <span class="ruby-comment"># =&gt; true</span>
248
+ </pre>
249
+
250
+ <p>Executing this action would yield something like the following:</p>
251
+
252
+ <pre>break [ OK ]
253
+ Press ENTER to continue</pre>
254
+
255
+ <p>While calling <a
256
+ href="Context.html#method-c-wait">Bauxite::Context.wait</a> directly would
257
+ yield:</p>
258
+
259
+ <pre>break Press EN
260
+ TER to continue
261
+ [ OK ]</pre>
262
+
263
+ </section>
264
+
265
+
266
+
267
+
268
+ <section id="5Buntitled-5D" class="documentation-section">
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+ </section>
279
+
280
+
281
+
282
+ <section id="Action+Methods" class="documentation-section">
283
+
284
+ <header class="documentation-section-title">
285
+ <h2>
286
+ Action Methods
287
+ </h2>
288
+ <span class="section-click-top">
289
+ <a href="#top">&uarr; top</a>
290
+ </span>
291
+ </header>
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+ <section id="public-instance-Action+Methods-method-details" class="method-section">
302
+ <header>
303
+ <h3>Public Instance Methods</h3>
304
+ </header>
305
+
306
+
307
+ <div id="method-i-alias_action" class="method-detail ">
308
+
309
+ <div class="method-heading">
310
+ <span class="method-name">alias_action</span><span
311
+ class="method-args">(name, action, *args)</span>
312
+
313
+ <span class="method-click-advice">click to toggle source</span>
314
+
315
+ </div>
316
+
317
+
318
+ <div class="method-description">
319
+
320
+ <p>Aliases <code>name</code> to <code>action</code> with additional arguments.</p>
321
+
322
+ <p>In <code>args</code> the variables <code>${1}</code>..<code>${n}</code>
323
+ will be expanded to the arguments given to the alias. Also
324
+ <code>${n*}</code> will be expanded to the space separated list of
325
+ arguments from the n-th on. Finally, <code>${n*q}</code> will behave like
326
+ <code>${n*}</code> except that each argument will be surrounded by quotes
327
+ (+“+) and quotes inside the argument will be doubled (+”“+).</p>
328
+
329
+ <p>Note that <code>action</code> can be any action except <code>alias</code>.
330
+ Also note that this action does not check for cyclic aliases (e.g. alias
331
+ <code>a</code> to <code>b</code> and alias <code>b</code> to
332
+ <code>a</code>). You should check that yourself.</p>
333
+
334
+ <p>Also note that this method provides an action named <code>alias</code> and
335
+ not alias_action.</p>
336
+
337
+ <p>For example:</p>
338
+
339
+ <pre class="ruby"><span class="ruby-keyword">alias</span> <span class="ruby-identifier">hey</span> <span class="ruby-identifier">echo</span> <span class="ruby-string">&quot;$1, nice to see you!&quot;</span>
340
+ <span class="ruby-identifier">hey</span> <span class="ruby-identifier">john</span>
341
+ <span class="ruby-comment"># =&gt; this would expand to</span>
342
+ <span class="ruby-comment"># echo &quot;john, nice to see you!&quot;</span>
343
+ </pre>
344
+
345
+
346
+
347
+
348
+ <div class="method-source-code" id="alias_action-source">
349
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/alias.rb, line 48</span>
350
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">alias_action</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
351
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">aliases</span>[<span class="ruby-identifier">name</span>] = ([<span class="ruby-identifier">action</span>] <span class="ruby-operator">+</span> (<span class="ruby-identifier">args</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-string">&#39;&quot;&#39;</span><span class="ruby-operator">+</span><span class="ruby-identifier">a</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-string">&#39;&quot;&quot;&#39;</span>, <span class="ruby-string">&#39;&#39;</span>)<span class="ruby-operator">+</span><span class="ruby-string">&#39;&quot;&#39;</span> })).<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)
352
+ <span class="ruby-keyword">end</span></pre>
353
+ </div>
354
+
355
+ </div>
356
+
357
+
358
+
359
+
360
+ </div>
361
+
362
+
363
+ <div id="method-i-assert" class="method-detail ">
364
+
365
+ <div class="method-heading">
366
+ <span class="method-name">assert</span><span
367
+ class="method-args">(selector, text)</span>
368
+
369
+ <span class="method-click-advice">click to toggle source</span>
370
+
371
+ </div>
372
+
373
+
374
+ <div class="method-description">
375
+
376
+ <p>Asserts that the value of the selected element matches <code>text</code>.</p>
377
+
378
+ <p><code>text</code> is a regular expression. <code>text</code> can be
379
+ surrounded by <code>/</code> characters followed by regular expression
380
+ flags.</p>
381
+
382
+ <p>For example:</p>
383
+
384
+ <pre class="ruby"><span class="ruby-comment"># assuming &lt;input type=&quot;text&quot; id=&quot;hello&quot; value=&quot;world&quot; /&gt;</span>
385
+ <span class="ruby-identifier">assert</span> <span class="ruby-identifier">hello</span> <span class="ruby-identifier">world</span>
386
+ <span class="ruby-identifier">assert</span> <span class="ruby-identifier">hello</span> <span class="ruby-identifier">wor</span>
387
+ <span class="ruby-identifier">assert</span> <span class="ruby-identifier">hello</span> <span class="ruby-operator">^</span><span class="ruby-identifier">wor</span>
388
+ <span class="ruby-identifier">assert</span> <span class="ruby-identifier">hello</span> <span class="ruby-regexp">/WorlD/i</span>
389
+ <span class="ruby-comment"># =&gt; these assertions would pass</span>
390
+ </pre>
391
+
392
+
393
+
394
+
395
+ <div class="method-source-code" id="assert-source">
396
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/assert.rb, line 38</span>
397
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">assert</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
398
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
399
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
400
+ <span class="ruby-identifier">actual</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">e</span>)
401
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">text</span>)
402
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">&quot;Assertion failed: expected &#39;#{text}&#39;, got &#39;#{actual}&#39;&quot;</span>
403
+ <span class="ruby-keyword">end</span>
404
+ <span class="ruby-keyword">true</span>
405
+ <span class="ruby-keyword">end</span>
406
+ <span class="ruby-keyword">end</span>
407
+ <span class="ruby-keyword">end</span></pre>
408
+ </div>
409
+
410
+ </div>
411
+
412
+
413
+
414
+
415
+ </div>
416
+
417
+
418
+ <div id="method-i-assertv" class="method-detail ">
419
+
420
+ <div class="method-heading">
421
+ <span class="method-name">assertv</span><span
422
+ class="method-args">(expected, actual)</span>
423
+
424
+ <span class="method-click-advice">click to toggle source</span>
425
+
426
+ </div>
427
+
428
+
429
+ <div class="method-description">
430
+
431
+ <p>Asserts that the <code>actual</code> text matches the <code>expected</code>
432
+ text.</p>
433
+
434
+ <p><code>expected</code> can be a regular expression. See <a
435
+ href="Action.html#method-i-assert">assert</a> for more details.</p>
436
+
437
+ <p>For example:</p>
438
+
439
+ <pre class="ruby"><span class="ruby-comment"># assuming ctx.variables[&#39;myvar&#39;] = &#39;myvalue1234&#39;</span>
440
+ <span class="ruby-identifier">assertv</span> <span class="ruby-string">&quot;^myvalue\d+$&quot;</span> <span class="ruby-string">&quot;${myvar}&quot;</span>
441
+ <span class="ruby-comment"># =&gt; this assertion would pass</span>
442
+ </pre>
443
+
444
+
445
+
446
+
447
+ <div class="method-source-code" id="assertv-source">
448
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/assertv.rb, line 34</span>
449
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">assertv</span>(<span class="ruby-identifier">expected</span>, <span class="ruby-identifier">actual</span>)
450
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">expected</span>)
451
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">&quot;Assertion failed: &#39;#{actual}&#39; does not match &#39;#{expected}&#39;&quot;</span>
452
+ <span class="ruby-keyword">end</span>
453
+ <span class="ruby-keyword">true</span>
454
+ <span class="ruby-keyword">end</span></pre>
455
+ </div>
456
+
457
+ </div>
458
+
459
+
460
+
461
+
462
+ </div>
463
+
464
+
465
+ <div id="method-i-break_action" class="method-detail ">
466
+
467
+ <div class="method-heading">
468
+ <span class="method-name">break_action</span><span
469
+ class="method-args">()</span>
470
+
471
+ <span class="method-click-advice">click to toggle source</span>
472
+
473
+ </div>
474
+
475
+
476
+ <div class="method-description">
477
+
478
+ <p>Prompts the user to press ENTER before resuming execution.</p>
479
+
480
+ <p>Note that this method provides an action named <code>break</code> and not
481
+ break_action.</p>
482
+
483
+ <p>See <a href="Context.html#method-c-wait">Bauxite::Context.wait</a>.</p>
484
+
485
+ <p>For example:</p>
486
+
487
+ <pre class="ruby"><span class="ruby-keyword">break</span>
488
+ <span class="ruby-comment"># =&gt; echoes &quot;Press ENTER to continue&quot; and waits for user input</span>
489
+ </pre>
490
+
491
+
492
+
493
+
494
+ <div class="method-source-code" id="break_action-source">
495
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/break.rb, line 36</span>
496
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">break_action</span>
497
+ <span class="ruby-identifier">lambda</span> { <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Context</span><span class="ruby-operator">::</span><span class="ruby-identifier">wait</span> }
498
+ <span class="ruby-keyword">end</span></pre>
499
+ </div>
500
+
501
+ </div>
502
+
503
+
504
+
505
+
506
+ </div>
507
+
508
+
509
+ <div id="method-i-click" class="method-detail ">
510
+
511
+ <div class="method-heading">
512
+ <span class="method-name">click</span><span
513
+ class="method-args">(selector)</span>
514
+
515
+ <span class="method-click-advice">click to toggle source</span>
516
+
517
+ </div>
518
+
519
+
520
+ <div class="method-description">
521
+
522
+ <p>Triggers the <code>click</code> event on the selected element.</p>
523
+
524
+ <p>For example:</p>
525
+
526
+ <pre class="ruby"><span class="ruby-comment"># assuming &lt;button type=&quot;button&quot; id=&quot;btn&quot;&gt;click me&lt;/button&gt;</span>
527
+ <span class="ruby-identifier">click</span> <span class="ruby-identifier">btn</span>
528
+ <span class="ruby-comment"># =&gt; this would click the button</span>
529
+ </pre>
530
+
531
+
532
+
533
+
534
+ <div class="method-source-code" id="click-source">
535
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/click.rb, line 32</span>
536
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">click</span>(<span class="ruby-identifier">selector</span>)
537
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">click</span> }
538
+ <span class="ruby-keyword">end</span></pre>
539
+ </div>
540
+
541
+ </div>
542
+
543
+
544
+
545
+
546
+ </div>
547
+
548
+
549
+ <div id="method-i-debug" class="method-detail ">
550
+
551
+ <div class="method-heading">
552
+ <span class="method-name">debug</span><span
553
+ class="method-args">()</span>
554
+
555
+ <span class="method-click-advice">click to toggle source</span>
556
+
557
+ </div>
558
+
559
+
560
+ <div class="method-description">
561
+
562
+ <p>Breaks into the debug console.</p>
563
+
564
+ <p>In the debug console you can type action strings and test their result.</p>
565
+
566
+ <p>The debug console supports a history of previously executed actions and
567
+ autocomplete (pressing the <code>TAB</code> key).</p>
568
+
569
+ <p>For example:</p>
570
+
571
+ <pre class="ruby"><span class="ruby-identifier">debug</span>
572
+ <span class="ruby-comment"># =&gt; this breaks into the debug console</span>
573
+ </pre>
574
+
575
+
576
+
577
+
578
+ <div class="method-source-code" id="debug-source">
579
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/debug.rb, line 35</span>
580
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">debug</span>
581
+ <span class="ruby-identifier">lambda</span> { <span class="ruby-identifier">_debug_process</span> }
582
+ <span class="ruby-keyword">end</span></pre>
583
+ </div>
584
+
585
+ </div>
586
+
587
+
588
+
589
+
590
+ </div>
591
+
592
+
593
+ <div id="method-i-echo" class="method-detail ">
594
+
595
+ <div class="method-heading">
596
+ <span class="method-name">echo</span><span
597
+ class="method-args">(text)</span>
598
+
599
+ <span class="method-click-advice">click to toggle source</span>
600
+
601
+ </div>
602
+
603
+
604
+ <div class="method-description">
605
+
606
+ <p>Prints the value of the specified <code>text</code>.</p>
607
+
608
+ <p><code>text</code> is subject to variable expansion (see <a
609
+ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
610
+
611
+ <p>For example:</p>
612
+
613
+ <pre class="ruby"><span class="ruby-identifier">echo</span> <span class="ruby-string">&quot;Hello World!&quot;</span>
614
+ <span class="ruby-comment"># =&gt; this would print &quot;Hello World!&quot; in the terminal window.</span>
615
+ </pre>
616
+
617
+
618
+
619
+
620
+ <div class="method-source-code" id="echo-source">
621
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/echo.rb, line 33</span>
622
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">echo</span>(<span class="ruby-identifier">text</span>)
623
+ <span class="ruby-keyword">true</span>
624
+ <span class="ruby-keyword">end</span></pre>
625
+ </div>
626
+
627
+ </div>
628
+
629
+
630
+
631
+
632
+ </div>
633
+
634
+
635
+ <div id="method-i-exec" class="method-detail ">
636
+
637
+ <div class="method-heading">
638
+ <span class="method-name">exec</span><span
639
+ class="method-args">(*command)</span>
640
+
641
+ <span class="method-click-advice">click to toggle source</span>
642
+
643
+ </div>
644
+
645
+
646
+ <div class="method-description">
647
+
648
+ <p>Executes <code>command</code>, optionally storing the results in a
649
+ variable.</p>
650
+
651
+ <p>If the first argument of <code>command</code> is <code>name=...</code> the
652
+ results of the execution will be assigned to the variable named
653
+ <code>name</code>.</p>
654
+
655
+ <p>For example:</p>
656
+
657
+ <pre class="ruby"><span class="ruby-identifier">exec</span> <span class="ruby-string">&quot;that_day=date --date=&#39;2001-01-01&#39; | cut -f 1 -d &#39; &#39;&quot;</span>
658
+ <span class="ruby-identifier">echo</span> <span class="ruby-string">&quot;${that_day}&quot;</span>
659
+ <span class="ruby-comment"># =&gt; this would print &#39;Mon&#39;</span>
660
+ </pre>
661
+
662
+
663
+
664
+
665
+ <div class="method-source-code" id="exec-source">
666
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/exec.rb, line 35</span>
667
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">exec</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">command</span>)
668
+ <span class="ruby-identifier">data</span> = <span class="ruby-identifier">command</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">&#39;=&#39;</span>, <span class="ruby-value">2</span>)
669
+ <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>
670
+ <span class="ruby-keyword">if</span> (<span class="ruby-identifier">data</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>)
671
+ <span class="ruby-identifier">name</span> = <span class="ruby-identifier">data</span>[<span class="ruby-value">0</span>]
672
+ <span class="ruby-identifier">command</span>[<span class="ruby-value">0</span>] = <span class="ruby-identifier">data</span>[<span class="ruby-value">1</span>]
673
+ <span class="ruby-keyword">end</span>
674
+
675
+ <span class="ruby-identifier">ret</span> = <span class="ruby-node">%x#{command.join(&#39; &#39;)}`</span>
676
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">ret</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>
677
+ <span class="ruby-keyword">end</span></pre>
678
+ </div>
679
+
680
+ </div>
681
+
682
+
683
+
684
+
685
+ </div>
686
+
687
+
688
+ <div id="method-i-js" class="method-detail ">
689
+
690
+ <div class="method-heading">
691
+ <span class="method-name">js</span><span
692
+ class="method-args">(script, name = nil)</span>
693
+
694
+ <span class="method-click-advice">click to toggle source</span>
695
+
696
+ </div>
697
+
698
+
699
+ <div class="method-description">
700
+
701
+ <p>Executes the specified Javascript <code>script</code>, optionally storing
702
+ the results the variable named <code>name</code>.</p>
703
+
704
+ <p>Note that if <code>name</code> is provided, the script must return a value
705
+ using the Javascript <code>return</code> statement.</p>
706
+
707
+ <p>For example:</p>
708
+
709
+ <pre class="ruby"><span class="ruby-identifier">js</span> <span class="ruby-string">&quot;return document.title&quot;</span> <span class="ruby-identifier">title_var</span>
710
+ <span class="ruby-identifier">echo</span> <span class="ruby-string">&quot;${title_var}&quot;</span>
711
+ <span class="ruby-comment"># =&gt; this would print the title of the page</span>
712
+ </pre>
713
+
714
+
715
+
716
+
717
+ <div class="method-source-code" id="js-source">
718
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/js.rb, line 36</span>
719
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">js</span>(<span class="ruby-identifier">script</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>)
720
+ <span class="ruby-identifier">result</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">execute_script</span>(<span class="ruby-identifier">script</span>)
721
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">result</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">name</span>
722
+ <span class="ruby-keyword">true</span>
723
+ <span class="ruby-keyword">end</span></pre>
724
+ </div>
725
+
726
+ </div>
727
+
728
+
729
+
730
+
731
+ </div>
732
+
733
+
734
+ <div id="method-i-load" class="method-detail ">
735
+
736
+ <div class="method-heading">
737
+ <span class="method-name">load</span><span
738
+ class="method-args">(file, *vars)</span>
739
+
740
+ <span class="method-click-advice">click to toggle source</span>
741
+
742
+ </div>
743
+
744
+
745
+ <div class="method-description">
746
+
747
+ <p>Load the specified file into an isolated variable context and execute the
748
+ actions specified. If the file does not exist, this action fails. See <a
749
+ href="Action.html#method-i-tryload">tryload</a> for a similar action that
750
+ skips if the file does not exist.</p>
751
+
752
+ <p><code>file</code> can be a path relative to the current test file.</p>
753
+
754
+ <p>An optional list of variables can be provided in <code>vars</code>. These
755
+ variables will override the value of the context variables for the
756
+ execution of the file (See <a
757
+ href="Context.html#method-i-with_vars">Bauxite::Context#with_vars</a>).</p>
758
+
759
+ <p>The syntax of the variable specification is:</p>
760
+
761
+ <pre>&quot;var1_name=var1_value&quot; &quot;var2_name=var2_value&quot; ...</pre>
762
+
763
+ <p>For example:</p>
764
+
765
+ <pre class="ruby"><span class="ruby-identifier">load</span> <span class="ruby-identifier">other_test</span>.<span class="ruby-identifier">bxt</span> <span class="ruby-string">&quot;othervar=value_just_for_other&quot;</span>
766
+ <span class="ruby-identifier">echo</span> <span class="ruby-string">&quot;${othervar}&quot;</span>
767
+ <span class="ruby-comment"># =&gt; this would load and execute other_test.bxt, injecting othervar</span>
768
+ <span class="ruby-comment"># into its context. After other_test.bxt completes, othervar will</span>
769
+ <span class="ruby-comment"># be restored to its original value (or be undefined if it didn&#39;t</span>
770
+ <span class="ruby-comment"># exist prior to the &#39;load&#39; call).</span>
771
+ </pre>
772
+
773
+
774
+
775
+
776
+ <div class="method-source-code" id="load-source">
777
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/load.rb, line 46</span>
778
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">load</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
779
+ <span class="ruby-identifier">tryload</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-operator">||</span> (<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">FileNotFoundError</span>, <span class="ruby-node">&quot;File not found: #{file}&quot;</span>)
780
+ <span class="ruby-keyword">end</span></pre>
781
+ </div>
782
+
783
+ </div>
784
+
785
+
786
+
787
+
788
+ </div>
789
+
790
+
791
+ <div id="method-i-open" class="method-detail ">
792
+
793
+ <div class="method-heading">
794
+ <span class="method-name">open</span><span
795
+ class="method-args">(url)</span>
796
+
797
+ <span class="method-click-advice">click to toggle source</span>
798
+
799
+ </div>
800
+
801
+
802
+ <div class="method-description">
803
+
804
+ <p>Opens the specified <code>url</code> in the browser.</p>
805
+
806
+ <p>For example:</p>
807
+
808
+ <pre class="ruby"><span class="ruby-identifier">open</span> <span class="ruby-string">&quot;http://www.ruby-lang.org&quot;</span>
809
+ <span class="ruby-comment"># =&gt; this would open http://www.ruby-lang.org in the browser window</span>
810
+ </pre>
811
+
812
+
813
+
814
+
815
+ <div class="method-source-code" id="open-source">
816
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/open.rb, line 31</span>
817
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">open</span>(<span class="ruby-identifier">url</span>)
818
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">navigate</span>.<span class="ruby-identifier">to</span> <span class="ruby-identifier">url</span>
819
+ <span class="ruby-keyword">end</span></pre>
820
+ </div>
821
+
822
+ </div>
823
+
824
+
825
+
826
+
827
+ </div>
828
+
829
+
830
+ <div id="method-i-params" class="method-detail ">
831
+
832
+ <div class="method-heading">
833
+ <span class="method-name">params</span><span
834
+ class="method-args">(*vars)</span>
835
+
836
+ <span class="method-click-advice">click to toggle source</span>
837
+
838
+ </div>
839
+
840
+
841
+ <div class="method-description">
842
+
843
+ <p>Asserts that the variables named <code>vars</code> are defined and not
844
+ empty.</p>
845
+
846
+ <p>For example:</p>
847
+
848
+ <pre class="ruby"><span class="ruby-identifier">params</span> <span class="ruby-identifier">host</span> <span class="ruby-identifier">db_name</span> <span class="ruby-identifier">username</span> <span class="ruby-identifier">password</span>
849
+ <span class="ruby-comment"># =&gt; this would fail if any of the four variables listed above</span>
850
+ <span class="ruby-comment"># is not defined or is empty</span>
851
+ </pre>
852
+
853
+
854
+
855
+
856
+ <div class="method-source-code" id="params-source">
857
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/params.rb, line 32</span>
858
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">params</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
859
+ <span class="ruby-identifier">missing</span> = <span class="ruby-identifier">vars</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> (<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">v</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&#39;&#39;</span>) <span class="ruby-operator">==</span> <span class="ruby-string">&#39;&#39;</span> }.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39;, &#39;</span>)
860
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">missing</span> <span class="ruby-operator">!=</span> <span class="ruby-string">&#39;&#39;</span>
861
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>,
862
+ <span class="ruby-node">&quot;Assertion failed: the following variables must be defined and not be empty: #{missing}.&quot;</span>
863
+ <span class="ruby-keyword">end</span>
864
+ <span class="ruby-keyword">true</span>
865
+ <span class="ruby-keyword">end</span></pre>
866
+ </div>
867
+
868
+ </div>
869
+
870
+
871
+
872
+
873
+ </div>
874
+
875
+
876
+ <div id="method-i-replace" class="method-detail ">
877
+
878
+ <div class="method-heading">
879
+ <span class="method-name">replace</span><span
880
+ class="method-args">(text, pattern, replacement, name)</span>
881
+
882
+ <span class="method-click-advice">click to toggle source</span>
883
+
884
+ </div>
885
+
886
+
887
+ <div class="method-description">
888
+
889
+ <p>Replaces the occurrences of <code>pattern</code> in <code>text</code> with
890
+ <code>replacement</code> and assigns the result to the variable named
891
+ <code>name</code>.</p>
892
+
893
+ <p>For example:</p>
894
+
895
+ <pre class="ruby"><span class="ruby-identifier">set</span> <span class="ruby-identifier">place</span> <span class="ruby-string">&quot;World&quot;</span>
896
+ <span class="ruby-identifier">replace</span> <span class="ruby-string">&quot;Hello ${place}&quot;</span> <span class="ruby-string">&quot;World&quot;</span> <span class="ruby-string">&quot;Universe&quot;</span> <span class="ruby-identifier">greeting</span>
897
+ <span class="ruby-identifier">echo</span> <span class="ruby-string">&quot;${greeting}!&quot;</span>
898
+ <span class="ruby-comment"># =&gt; this would print &#39;Hello Universe!&#39;</span>
899
+ </pre>
900
+
901
+
902
+
903
+
904
+ <div class="method-source-code" id="replace-source">
905
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/replace.rb, line 34</span>
906
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">replace</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">pattern</span>, <span class="ruby-identifier">replacement</span>, <span class="ruby-identifier">name</span>)
907
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">text</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">pattern</span>), <span class="ruby-identifier">replacement</span>)
908
+ <span class="ruby-keyword">end</span></pre>
909
+ </div>
910
+
911
+ </div>
912
+
913
+
914
+
915
+
916
+ </div>
917
+
918
+
919
+ <div id="method-i-reset" class="method-detail ">
920
+
921
+ <div class="method-heading">
922
+ <span class="method-name">reset</span><span
923
+ class="method-args">()</span>
924
+
925
+ <span class="method-click-advice">click to toggle source</span>
926
+
927
+ </div>
928
+
929
+
930
+ <div class="method-description">
931
+
932
+ <p>Resets the test engine by closing and reopening the browser. As a side
933
+ effect of resetting the test engine, all cookies, logins and cache items
934
+ are destroyed.</p>
935
+
936
+ <p>For example:</p>
937
+
938
+ <pre class="ruby"><span class="ruby-identifier">reset</span>
939
+ <span class="ruby-comment"># =&gt; this would close and re-open the browser window, removing </span>
940
+ <span class="ruby-comment"># cookies, cache, login sessions, etc.</span>
941
+ </pre>
942
+
943
+
944
+
945
+
946
+ <div class="method-source-code" id="reset-source">
947
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/reset.rb, line 34</span>
948
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">reset</span>()
949
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">reset_driver</span>
950
+ <span class="ruby-keyword">end</span></pre>
951
+ </div>
952
+
953
+ </div>
954
+
955
+
956
+
957
+
958
+ </div>
959
+
960
+
961
+ <div id="method-i-return_action" class="method-detail ">
962
+
963
+ <div class="method-heading">
964
+ <span class="method-name">return_action</span><span
965
+ class="method-args">(*vars)</span>
966
+
967
+ <span class="method-click-advice">click to toggle source</span>
968
+
969
+ </div>
970
+
971
+
972
+ <div class="method-description">
973
+
974
+ <p>Returns the specified variables to the parent scope (if any).</p>
975
+
976
+ <p>If <code>vars</code> is <code>*</code> every variable defined in the
977
+ current scope will be returned to the parent scope.</p>
978
+
979
+ <p>The syntax of the variable specification is:</p>
980
+
981
+ <pre>&quot;var1_name&quot; &quot;var2_name&quot; ...</pre>
982
+
983
+ <p>Note that this method provides an action named <code>return</code> and not
984
+ return_action.</p>
985
+
986
+ <p>For example:</p>
987
+
988
+ <pre class="ruby"><span class="ruby-identifier">set</span> <span class="ruby-identifier">result</span> <span class="ruby-string">&quot;42&quot;</span>
989
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span>
990
+ <span class="ruby-comment"># =&gt; this would inject the result variable (whose value is 42)</span>
991
+ <span class="ruby-comment"># into the calling context.</span>
992
+ </pre>
993
+
994
+ <p>Full example (see <a href="Action.html#method-i-load">load</a>, <a
995
+ href="Action.html#method-i-write">write</a>, <a
996
+ href="Action.html#method-i-click">click</a>, <a
997
+ href="Action.html#method-i-store">store</a> and <a
998
+ href="Action.html#method-i-assert">assert</a> for more details):</p>
999
+
1000
+ <pre class="ruby"><span class="ruby-comment"># in main.bxt</span>
1001
+ <span class="ruby-identifier">load</span> <span class="ruby-identifier">login</span>.<span class="ruby-identifier">txt</span> <span class="ruby-string">&quot;username=jdoe&quot;</span> <span class="ruby-string">&quot;password=hello world!&quot;</span>
1002
+
1003
+ <span class="ruby-comment"># in login.bxt</span>
1004
+ <span class="ruby-identifier">write</span> <span class="ruby-identifier">id</span>=<span class="ruby-identifier">user</span> <span class="ruby-string">&quot;${username}&quot;</span>
1005
+ <span class="ruby-identifier">write</span> <span class="ruby-identifier">id</span>=<span class="ruby-identifier">pass</span> <span class="ruby-string">&quot;${password}&quot;</span>
1006
+ <span class="ruby-identifier">click</span> <span class="ruby-identifier">id</span>=<span class="ruby-identifier">login</span>
1007
+ <span class="ruby-identifier">store</span> <span class="ruby-identifier">id</span>=<span class="ruby-identifier">loginName</span> <span class="ruby-identifier">fullName</span>
1008
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">fullName</span>
1009
+
1010
+ <span class="ruby-comment"># back in main.bxt</span>
1011
+ <span class="ruby-identifier">assert</span> <span class="ruby-identifier">id</span>=<span class="ruby-identifier">greeting</span> <span class="ruby-string">&quot;Welcome ${fullName}!&quot;</span>
1012
+ <span class="ruby-comment"># =&gt; this assertion uses the variable returned from login.bxt</span>
1013
+ </pre>
1014
+
1015
+
1016
+
1017
+
1018
+ <div class="method-source-code" id="return_action-source">
1019
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/return.rb, line 58</span>
1020
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">return_action</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
1021
+ <span class="ruby-identifier">rets</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">&#39;__RETURN__&#39;</span>] <span class="ruby-operator">||</span> []
1022
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">&#39;__RETURN__&#39;</span>] = <span class="ruby-identifier">rets</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">vars</span>
1023
+ <span class="ruby-keyword">end</span></pre>
1024
+ </div>
1025
+
1026
+ </div>
1027
+
1028
+
1029
+
1030
+
1031
+ </div>
1032
+
1033
+
1034
+ <div id="method-i-ruby" class="method-detail ">
1035
+
1036
+ <div class="method-heading">
1037
+ <span class="method-name">ruby</span><span
1038
+ class="method-args">(file, *vars)</span>
1039
+
1040
+ <span class="method-click-advice">click to toggle source</span>
1041
+
1042
+ </div>
1043
+
1044
+
1045
+ <div class="method-description">
1046
+
1047
+ <p>Load the specified ruby file into an isolated variable context and execute
1048
+ the ruby code.</p>
1049
+
1050
+ <p><code>file</code> can be a path relative to the current test file.</p>
1051
+
1052
+ <p>An optional list of variables can be provided in <code>vars</code>. See <a
1053
+ href="Action.html#method-i-load">load</a>.</p>
1054
+
1055
+ <p>The ruby action file must contain a single lambda that takes a <a
1056
+ href="Context.html">Context</a> instance as its only argument.</p>
1057
+
1058
+ <p>For example:</p>
1059
+
1060
+ <pre class="ruby"><span class="ruby-comment"># === my_test.rb ======= #</span>
1061
+ <span class="ruby-identifier">lambda</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ctx</span><span class="ruby-operator">|</span>
1062
+ <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">exec_action</span> <span class="ruby-string">&#39;echo &quot;${message}&quot;&#39;</span>
1063
+ <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">navigate</span>.<span class="ruby-identifier">to</span> <span class="ruby-string">&#39;http://www.ruby-lang.org&#39;</span>
1064
+ <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">&#39;new&#39;</span>] = <span class="ruby-string">&#39;from ruby!&#39;</span>
1065
+ <span class="ruby-identifier">ctx</span>.<span class="ruby-identifier">exec_action</span> <span class="ruby-string">&#39;return new&#39;</span>
1066
+ <span class="ruby-keyword">end</span>
1067
+ <span class="ruby-comment"># === end my_test.rb === #</span>
1068
+
1069
+ <span class="ruby-comment"># in main.bxt</span>
1070
+ <span class="ruby-identifier">ruby</span> <span class="ruby-identifier">my_test</span>.<span class="ruby-identifier">rb</span> <span class="ruby-string">&quot;message=Hello World!&quot;</span>
1071
+ <span class="ruby-identifier">echo</span> <span class="ruby-string">&quot;${new}&quot;</span>
1072
+ <span class="ruby-comment"># =&gt; this would print &#39;from ruby!&#39;</span>
1073
+ </pre>
1074
+
1075
+
1076
+
1077
+
1078
+ <div class="method-source-code" id="ruby-source">
1079
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/ruby.rb, line 50</span>
1080
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">ruby</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
1081
+ <span class="ruby-comment"># _load_file_action is defined in tryload.rb</span>
1082
+ <span class="ruby-identifier">_load_file_action</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
1083
+ <span class="ruby-identifier">content</span> = <span class="ruby-string">&#39;&#39;</span>
1084
+ <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">f</span>, <span class="ruby-string">&#39;r&#39;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">ff</span><span class="ruby-operator">|</span> <span class="ruby-identifier">content</span> = <span class="ruby-identifier">ff</span>.<span class="ruby-identifier">read</span> }
1085
+ <span class="ruby-identifier">eval</span>(<span class="ruby-identifier">content</span>).<span class="ruby-identifier">call</span>(<span class="ruby-ivar">@ctx</span>)
1086
+ <span class="ruby-keyword">end</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">FileNotFoundError</span>, <span class="ruby-node">&quot;File not found: #{file}&quot;</span>)
1087
+ <span class="ruby-keyword">end</span></pre>
1088
+ </div>
1089
+
1090
+ </div>
1091
+
1092
+
1093
+
1094
+
1095
+ </div>
1096
+
1097
+
1098
+ <div id="method-i-set" class="method-detail ">
1099
+
1100
+ <div class="method-heading">
1101
+ <span class="method-name">set</span><span
1102
+ class="method-args">(name, value)</span>
1103
+
1104
+ <span class="method-click-advice">click to toggle source</span>
1105
+
1106
+ </div>
1107
+
1108
+
1109
+ <div class="method-description">
1110
+
1111
+ <p>Sets the variable named <code>name</code> to the <code>value</code>
1112
+ specified.</p>
1113
+
1114
+ <p>Both <code>name</code> and <code>value</code> are subject to variable
1115
+ expansion (see <a
1116
+ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
1117
+
1118
+ <p>For example:</p>
1119
+
1120
+ <pre class="ruby"><span class="ruby-identifier">set</span> <span class="ruby-identifier">one</span> <span class="ruby-string">&quot;uno&quot;</span>
1121
+ <span class="ruby-identifier">set</span> <span class="ruby-identifier">two</span> <span class="ruby-string">&quot;${one} + ${one}&quot;</span>
1122
+ <span class="ruby-identifier">echo</span> <span class="ruby-string">&quot;${two}&quot;</span>
1123
+ <span class="ruby-comment"># =&gt; this would print &#39;uno + uno&#39;</span>
1124
+ </pre>
1125
+
1126
+
1127
+
1128
+
1129
+ <div class="method-source-code" id="set-source">
1130
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/set.rb, line 36</span>
1131
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">set</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>)
1132
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
1133
+ <span class="ruby-keyword">end</span></pre>
1134
+ </div>
1135
+
1136
+ </div>
1137
+
1138
+
1139
+
1140
+
1141
+ </div>
1142
+
1143
+
1144
+ <div id="method-i-source" class="method-detail ">
1145
+
1146
+ <div class="method-heading">
1147
+ <span class="method-name">source</span><span
1148
+ class="method-args">(text)</span>
1149
+
1150
+ <span class="method-click-advice">click to toggle source</span>
1151
+
1152
+ </div>
1153
+
1154
+
1155
+ <div class="method-description">
1156
+
1157
+ <p>Asserts that the page source matches <code>text</code>.</p>
1158
+
1159
+ <p><code>text</code> can be a regular expression. See <a
1160
+ href="Action.html#method-i-assert">assert</a> for more details.</p>
1161
+
1162
+ <p>For example:</p>
1163
+
1164
+ <pre class="ruby"><span class="ruby-comment"># assuming &lt;html&gt;&lt;body&gt;Hello World!&lt;/body&gt;&lt;/html&gt;</span>
1165
+ <span class="ruby-identifier">source</span> <span class="ruby-string">&quot;Hello.*!&quot;</span>
1166
+ <span class="ruby-comment"># =&gt; this assertion would pass</span>
1167
+ </pre>
1168
+
1169
+
1170
+
1171
+
1172
+ <div class="method-source-code" id="source-source">
1173
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/source.rb, line 34</span>
1174
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">source</span>(<span class="ruby-identifier">text</span>)
1175
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
1176
+ <span class="ruby-identifier">actual</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">page_source</span>
1177
+ <span class="ruby-identifier">verbose</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">options</span>[<span class="ruby-value">:verbose</span>] <span class="ruby-operator">?</span> <span class="ruby-node">&quot;\nPage source:\n#{actual}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;&#39;</span>
1178
+ <span class="ruby-keyword">unless</span> <span class="ruby-identifier">actual</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">_pattern</span>(<span class="ruby-identifier">text</span>)
1179
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">&quot;Assertion failed: page source does not match &#39;#{text}&#39;#{verbose}&quot;</span>
1180
+ <span class="ruby-keyword">end</span>
1181
+ <span class="ruby-keyword">true</span>
1182
+ <span class="ruby-keyword">end</span>
1183
+ <span class="ruby-keyword">end</span></pre>
1184
+ </div>
1185
+
1186
+ </div>
1187
+
1188
+
1189
+
1190
+
1191
+ </div>
1192
+
1193
+
1194
+ <div id="method-i-store" class="method-detail ">
1195
+
1196
+ <div class="method-heading">
1197
+ <span class="method-name">store</span><span
1198
+ class="method-args">(selector, name)</span>
1199
+
1200
+ <span class="method-click-advice">click to toggle source</span>
1201
+
1202
+ </div>
1203
+
1204
+
1205
+ <div class="method-description">
1206
+
1207
+ <p>Sets the variable named <code>name</code> to the value of the selected
1208
+ element.</p>
1209
+
1210
+ <p><code>name</code> is subject to variable expansion (see <a
1211
+ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
1212
+
1213
+ <p>For example:</p>
1214
+
1215
+ <pre class="ruby"><span class="ruby-comment"># assuming &lt;span id=&quot;name&quot;&gt;John&lt;/span&gt;</span>
1216
+ <span class="ruby-identifier">store</span> <span class="ruby-identifier">id</span>=<span class="ruby-identifier">name</span> <span class="ruby-identifier">firstName</span>
1217
+ <span class="ruby-identifier">echo</span> <span class="ruby-node">&quot;${firstName}
1218
+ # =&gt; this would print &#39;John&#39;
1219
+ </span></pre>
1220
+
1221
+
1222
+
1223
+
1224
+ <div class="method-source-code" id="store-source">
1225
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/store.rb, line 35</span>
1226
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">store</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">name</span>)
1227
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">get_value</span>(<span class="ruby-identifier">e</span>) }
1228
+ <span class="ruby-keyword">end</span></pre>
1229
+ </div>
1230
+
1231
+ </div>
1232
+
1233
+
1234
+
1235
+
1236
+ </div>
1237
+
1238
+
1239
+ <div id="method-i-test" class="method-detail ">
1240
+
1241
+ <div class="method-heading">
1242
+ <span class="method-name">test</span><span
1243
+ class="method-args">(file, name = nil)</span>
1244
+
1245
+ <span class="method-click-advice">click to toggle source</span>
1246
+
1247
+ </div>
1248
+
1249
+
1250
+ <div class="method-description">
1251
+
1252
+ <p>Load <code>file</code> using the <a
1253
+ href="Action.html#method-i-load">load</a> action into a new test context.</p>
1254
+
1255
+ <p>If <code>name</code> is specified, it will be used as the test name.</p>
1256
+
1257
+ <p>If any action in the test context fails, the whole test context fails, and
1258
+ the execution continues with the next test context (if any).</p>
1259
+
1260
+ <p>For example:</p>
1261
+
1262
+ <pre class="ruby"><span class="ruby-identifier">test</span> <span class="ruby-identifier">mytest</span>.<span class="ruby-identifier">bxt</span> <span class="ruby-string">&quot;My Test&quot;</span>
1263
+ <span class="ruby-comment"># =&gt; this would load mytest.bxt into a new test context</span>
1264
+ <span class="ruby-comment"># named &quot;My Test&quot;</span>
1265
+ </pre>
1266
+
1267
+
1268
+
1269
+
1270
+ <div class="method-source-code" id="test-source">
1271
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/test.rb, line 37</span>
1272
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">test</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>)
1273
+ <span class="ruby-identifier">delayed</span> = <span class="ruby-identifier">load</span>(<span class="ruby-identifier">file</span>)
1274
+
1275
+ <span class="ruby-identifier">lambda</span> <span class="ruby-keyword">do</span>
1276
+ <span class="ruby-keyword">begin</span>
1277
+ <span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>
1278
+ <span class="ruby-identifier">status</span> = <span class="ruby-string">&#39;ERROR&#39;</span>
1279
+ <span class="ruby-identifier">error</span> = <span class="ruby-keyword">nil</span>
1280
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">&#39;__RAISE_ERROR__&#39;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span> }) <span class="ruby-keyword">do</span>
1281
+ <span class="ruby-identifier">delayed</span>.<span class="ruby-identifier">call</span>
1282
+ <span class="ruby-identifier">status</span> = <span class="ruby-string">&#39;OK&#39;</span>
1283
+ <span class="ruby-keyword">end</span>
1284
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
1285
+ <span class="ruby-identifier">error</span> = <span class="ruby-identifier">e</span>
1286
+ <span class="ruby-keyword">ensure</span>
1287
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">tests</span> <span class="ruby-operator">&lt;&lt;</span> {
1288
+ <span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">file</span>,
1289
+ <span class="ruby-value">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">status</span>,
1290
+ <span class="ruby-value">:time</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">t</span>,
1291
+ <span class="ruby-value">:error</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">error</span>
1292
+ }
1293
+ <span class="ruby-keyword">end</span>
1294
+ <span class="ruby-keyword">end</span>
1295
+ <span class="ruby-keyword">end</span></pre>
1296
+ </div>
1297
+
1298
+ </div>
1299
+
1300
+
1301
+
1302
+
1303
+ </div>
1304
+
1305
+
1306
+ <div id="method-i-tryload" class="method-detail ">
1307
+
1308
+ <div class="method-heading">
1309
+ <span class="method-name">tryload</span><span
1310
+ class="method-args">(file, *vars)</span>
1311
+
1312
+ <span class="method-click-advice">click to toggle source</span>
1313
+
1314
+ </div>
1315
+
1316
+
1317
+ <div class="method-description">
1318
+
1319
+ <p>Load the specified file into an isolated variable context and execute the
1320
+ actions specified. If the file does not exist, this action skips. See <a
1321
+ href="Action.html#method-i-load">load</a> for a similar action that fails
1322
+ if the file does not exist.</p>
1323
+
1324
+ <p><code>file</code> can be a path relative to the current test file.</p>
1325
+
1326
+ <p>An optional list of variables can be provided in <code>vars</code>. These
1327
+ variables will override the value of the context variables for the
1328
+ execution of the file (See <a
1329
+ href="Context.html#method-i-with_vars">Bauxite::Context#with_vars</a>).</p>
1330
+
1331
+ <p>The syntax of the variable specification is:</p>
1332
+
1333
+ <pre>&quot;var1_name=var1_value&quot; &quot;var2_name=var2_value&quot; ...</pre>
1334
+
1335
+ <p>For example:</p>
1336
+
1337
+ <pre class="ruby"><span class="ruby-identifier">tryload</span> <span class="ruby-identifier">other_test</span>.<span class="ruby-identifier">bxt</span>
1338
+ <span class="ruby-identifier">tryload</span> <span class="ruby-identifier">nonexistent_file</span>.<span class="ruby-identifier">bxt</span>
1339
+ <span class="ruby-comment"># =&gt; this would load and execute other_test.bxt, then silently fail</span>
1340
+ <span class="ruby-comment"># to execute nonexistent_file.bxt without failing the test.</span>
1341
+ </pre>
1342
+
1343
+
1344
+
1345
+
1346
+ <div class="method-source-code" id="tryload-source">
1347
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/tryload.rb, line 44</span>
1348
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">tryload</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>)
1349
+ <span class="ruby-identifier">_load_file_action</span>(<span class="ruby-identifier">file</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">vars</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
1350
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">parse_file</span>(<span class="ruby-identifier">f</span>)
1351
+ <span class="ruby-keyword">end</span>
1352
+ <span class="ruby-keyword">end</span></pre>
1353
+ </div>
1354
+
1355
+ </div>
1356
+
1357
+
1358
+
1359
+
1360
+ </div>
1361
+
1362
+
1363
+ <div id="method-i-wait" class="method-detail ">
1364
+
1365
+ <div class="method-heading">
1366
+ <span class="method-name">wait</span><span
1367
+ class="method-args">(seconds)</span>
1368
+
1369
+ <span class="method-click-advice">click to toggle source</span>
1370
+
1371
+ </div>
1372
+
1373
+
1374
+ <div class="method-description">
1375
+
1376
+ <p>Wait for the specified number of <code>seconds</code>.</p>
1377
+
1378
+ <p>For example:</p>
1379
+
1380
+ <pre class="ruby"><span class="ruby-identifier">wait</span> <span class="ruby-value">5</span>
1381
+ <span class="ruby-comment"># =&gt; this would wait for 5 seconds and then continue</span>
1382
+ </pre>
1383
+
1384
+
1385
+
1386
+
1387
+ <div class="method-source-code" id="wait-source">
1388
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/wait.rb, line 31</span>
1389
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">wait</span>(<span class="ruby-identifier">seconds</span>)
1390
+ <span class="ruby-identifier">seconds</span> = <span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">to_i</span>
1391
+ <span class="ruby-identifier">seconds</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
1392
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">progress</span>(<span class="ruby-identifier">seconds</span><span class="ruby-operator">-</span><span class="ruby-identifier">i</span>)
1393
+ <span class="ruby-identifier">sleep</span>(<span class="ruby-value">1.0</span>)
1394
+ <span class="ruby-keyword">end</span>
1395
+ <span class="ruby-keyword">end</span></pre>
1396
+ </div>
1397
+
1398
+ </div>
1399
+
1400
+
1401
+
1402
+
1403
+ </div>
1404
+
1405
+
1406
+ <div id="method-i-write" class="method-detail ">
1407
+
1408
+ <div class="method-heading">
1409
+ <span class="method-name">write</span><span
1410
+ class="method-args">(selector, text)</span>
1411
+
1412
+ <span class="method-click-advice">click to toggle source</span>
1413
+
1414
+ </div>
1415
+
1416
+
1417
+ <div class="method-description">
1418
+
1419
+ <p>Sets the value of the selected element to <code>text</code>.</p>
1420
+
1421
+ <p><code>text</code> is subject to variable expansion (see <a
1422
+ href="Context.html#method-i-expand">Bauxite::Context#expand</a>).</p>
1423
+
1424
+ <p>For example:</p>
1425
+
1426
+ <pre class="ruby"><span class="ruby-comment"># assuming &lt;input type=&quot;text&quot; name=&quot;username&quot; /&gt;</span>
1427
+ <span class="ruby-identifier">write</span> <span class="ruby-identifier">name</span>=<span class="ruby-identifier">username</span> <span class="ruby-string">&quot;John&quot;</span>
1428
+ <span class="ruby-comment"># =&gt; this would type the word &#39;John&#39; in the username textbox</span>
1429
+ </pre>
1430
+
1431
+
1432
+
1433
+
1434
+ <div class="method-source-code" id="write-source">
1435
+ <pre><span class="ruby-comment"># File lib/bauxite/actions/write.rb, line 34</span>
1436
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">write</span>(<span class="ruby-identifier">selector</span>, <span class="ruby-identifier">text</span>)
1437
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">selector</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
1438
+ <span class="ruby-identifier">e</span>.<span class="ruby-identifier">clear</span>
1439
+ <span class="ruby-identifier">e</span>.<span class="ruby-identifier">send_keys</span>(<span class="ruby-identifier">text</span>)
1440
+ <span class="ruby-keyword">end</span>
1441
+ <span class="ruby-keyword">end</span></pre>
1442
+ </div>
1443
+
1444
+ </div>
1445
+
1446
+
1447
+
1448
+
1449
+ </div>
1450
+
1451
+
1452
+ </section>
1453
+
1454
+ </section>
1455
+ </main>
1456
+
1457
+
1458
+ <footer id="validator-badges" role="contentinfo">
1459
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
1460
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
1461
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
1462
+ </footer>
1463
+