symbiont 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,32 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- symbiont (0.1.2)
4
+ symbiont (0.1.3)
5
5
  watir-webdriver (= 0.6.1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  addressable (2.2.8)
11
+ builder (3.0.0)
11
12
  childprocess (0.3.2)
12
13
  ffi (~> 1.0.6)
14
+ cucumber (1.2.1)
15
+ builder (>= 2.1.2)
16
+ diff-lcs (>= 1.1.3)
17
+ gherkin (~> 2.11.0)
18
+ json (>= 1.4.6)
13
19
  diff-lcs (1.1.3)
14
20
  ffi (1.0.11)
21
+ gherkin (2.11.1-x86-mingw32)
22
+ json (>= 1.4.6)
23
+ json (1.7.3)
15
24
  libwebsocket (0.1.3)
16
25
  addressable
17
26
  multi_json (1.3.5)
18
- rspec (2.10.0)
19
- rspec-core (~> 2.10.0)
20
- rspec-expectations (~> 2.10.0)
21
- rspec-mocks (~> 2.10.0)
22
- rspec-core (2.10.0)
23
- rspec-expectations (2.10.0)
27
+ rspec (2.11.0)
28
+ rspec-core (~> 2.11.0)
29
+ rspec-expectations (~> 2.11.0)
30
+ rspec-mocks (~> 2.11.0)
31
+ rspec-core (2.11.0)
32
+ rspec-expectations (2.11.1)
24
33
  diff-lcs (~> 1.1.3)
25
- rspec-mocks (2.10.1)
34
+ rspec-mocks (2.11.1)
26
35
  rubyzip (0.9.8)
27
- selenium-webdriver (2.22.1)
36
+ selenium-webdriver (2.24.0)
28
37
  childprocess (>= 0.2.5)
29
- ffi (~> 1.0)
30
38
  libwebsocket (~> 0.1.3)
31
39
  multi_json (~> 1.0)
32
40
  rubyzip
@@ -42,7 +50,8 @@ PLATFORMS
42
50
  x86-mingw32
43
51
 
44
52
  DEPENDENCIES
45
- rspec (= 2.10.0)
53
+ cucumber (= 1.2.1)
54
+ rspec (= 2.11.0)
46
55
  simplecov (= 0.6.4)
47
56
  symbiont!
48
57
  yard (= 0.8.2.1)
data/HISTORY.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Change Log and History
2
2
  ======================
3
3
 
4
+ Version 0.1.4 / 2012-08-06
5
+ --------------------------
6
+
7
+ This release introduces the ability to be a little more flexible and expansive with the locators that are used as well as to allow custom locators by mapping them to existing locators. Partial support has also been added for using CSS selectors, although it is questionable if that will ultimately remain. This is a start at cleaning up the logic regarding how locators are currently handled for the various web objects.
8
+
9
+
4
10
  Version 0.1.3 / 2012-07-15
5
11
  --------------------------
6
12
 
data/README.md CHANGED
@@ -8,6 +8,7 @@ The Symbiont gem is designed to provide an open framework for running automated
8
8
 
9
9
  Right now the best information on the purpose of this project and how it works can be found on [my Symbiont-tagged blog posts](http://testerstories.com/?cat=16).
10
10
 
11
+
11
12
  Installation
12
13
  ------------
13
14
 
@@ -23,8 +24,15 @@ Or install it yourself as:
23
24
 
24
25
  $ gem install symbiont
25
26
 
26
- Meaning
27
- -------
27
+
28
+ Using Symbiont
29
+ --------------
30
+
31
+ Check out the [Symbiont Wiki](https://github.com/jnyman/symbiont/wiki) for details on how to use Symbiont.
32
+
33
+
34
+ Why call it Symbiont?
35
+ ---------------------
28
36
 
29
37
  A "symbiont" is an organism in a symbiotic (mutually beneficial) relationship. Some of these relationships are called _obligate_, which means that both organisms need each other in order to survive. Other such relationships are called _facultative_, meaning that both organisms don't strictly need each other to survive, but they stand a better chance if they do.
30
38
 
@@ -32,6 +40,7 @@ Symbiotic relationships include associations in which one organism lives on anot
32
40
 
33
41
  So, with that bit of context, think of this gem as a facultative, endosymbiotic organism that lives within your test logic, giving it strength and sustenance.
34
42
 
43
+
35
44
  Contributing
36
45
  ------------
37
46
 
@@ -41,7 +50,16 @@ Contributing
41
50
  4. Push to the branch (`git push origin my-new-feature`)
42
51
  5. Create new Pull Request
43
52
 
53
+
54
+ Credits
55
+ -------
56
+
57
+ Thanks to Jeff Morgan (http://www.cheezyworld.com/) for his page-object gem, Alister Scott (http://watirmelon.com) for his watir-page-helper gem, and Nat Ritmeyer (http://www.natontesting.com/) for his SitePrism gem. I learned a lot from analyzing their code and working to craft my own solution around theirs. Rather than fork their projects, my changes were systemic enough to warrant creating a new project.
58
+
59
+
44
60
  Copyright
45
61
  ---------
46
62
 
47
63
  See the LICENSE file for details.
64
+
65
+ In short, Lucid is under an MIT license. Since I'm borrowing from many other people, just as they borrowed from many other people before them, I'm just establishing I wrote _this_ particular version. (If nothing else, this means you know who to blame.)
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rspec/core/rake_task'
4
+ require 'cucumber/rake/task'
4
5
  require 'yard'
5
6
 
6
7
  RSpec::Core::RakeTask.new do |c|
@@ -24,4 +25,10 @@ namespace :spec do
24
25
  end
25
26
  end
26
27
 
28
+ namespace :specs do
29
+ Cucumber::Rake::Task.new(:watir, "Run Cucumber with Watir") do |config|
30
+ config.profile = 'default'
31
+ end
32
+ end
33
+
27
34
  task :default => :spec
@@ -7,7 +7,7 @@
7
7
 
8
8
  <div class="indent">
9
9
  <p>Here is a link with more than one way to identify it.</p>
10
- <p><a href="success_1" id="avengersID" class="avengersClass" name="avengersName">Avengers Assemble</a></p>
10
+ <p><a href="success_1" id="avengersID" class="avengersClass" name="avengersName" title="Click to Assemble">Avengers Assemble</a></p>
11
11
 
12
12
  <p>Here are two links that are identical for index (implicit) but not link location (explicit).</p>
13
13
  <p><a href="success_1">Justice League Unite</a><br />
@@ -65,7 +65,17 @@
65
65
 
66
66
  <div class="group">
67
67
  <p>This grouping contains some common web objects that are placed on forms or pages to allow selections. Note that some are disabled.</p>
68
-
68
+ <p><strong>Choose Your Subatomic Particles (More Than One):</strong></p>
69
+ <select id="subatomicID" multiple="multiple">
70
+ <option value="electron">Electron</option>
71
+ <option value="neutron">Neutron</option>
72
+ <option value="quark">Quark</option>
73
+ <option value="higgs">Higgs Boson</option>
74
+ <option value="neutrino">Neutrino</option>
75
+ <option value="graviton">Graviton</option>
76
+ <option value="photon">Photon</option>
77
+ </select>
78
+
69
79
  <p><strong>Choose Your Physics Concepts:</strong></p>
70
80
  <select id="physicsConceptsID" class="physicsConceptsClass" name="physicsConceptsName">
71
81
  <option value="option1">Quantum Entanglement</option>
@@ -105,68 +105,72 @@ module Symbiont
105
105
  # Link objects are of type: Symbiont::WebObjects::Link
106
106
  # @see Symbiont::Generators#link
107
107
  def get_link_for(locator)
108
- reference_web_object("link(locator)", WebObjects::Link, locator)
108
+ action = check_for_css("link(locator)", locator)
109
+ reference_web_object(action, WebObjects::Link, locator)
109
110
  end
110
111
 
111
112
  # Platform method to get text of link object.
112
113
  # @see Symbiont::Generators#link
113
114
  def get_link_text_for(locator)
114
- access_web_object("link(locator).text", locator)
115
+ access_web_object("link(locator).text", WebObjects::Link, locator)
115
116
  end
116
117
 
117
118
  # Platform method to click a link object.
118
119
  # @see Symbiont::Generators#link
119
120
  def click_link_for(locator)
120
- access_web_object("link(locator).click", locator)
121
+ action = check_for_css("link(locator)", locator)
122
+ access_web_object("#{action}.click", WebObjects::Link, locator)
121
123
  end
122
124
 
123
125
  # Platform method to check if link object exists.
124
126
  # @see Symbiont::Generators#link
125
127
  def check_link_for_existence(locator)
126
- access_web_object("link(locator).exists?", locator)
128
+ access_web_object("link(locator).exists?", WebObjects::Link, locator)
127
129
  end
128
130
 
129
131
  # Platform method to check if link object is visible.
130
132
  # @see Symbiont::Generators#link
131
133
  def check_link_for_visibility(locator)
132
- access_web_object("link(locator).visible?", locator)
134
+ access_web_object("link(locator).visible?", WebObjects::Link, locator)
133
135
  end
134
136
 
135
137
  # Platform method to return a button object.
136
138
  # Button objects are of type: Symbiont::WebObjects::Button
137
139
  # @see Symbiont::Generators#button
138
140
  def get_button_for(locator)
141
+ action = check_for_css("button(locator)", locator)
139
142
  reference_web_object("button(locator)", WebObjects::Button, locator)
140
143
  end
141
144
 
142
145
  # Platform method to get text of button object.
143
146
  # @see Symbiont::Generators#button
144
147
  def get_button_text_for(locator)
145
- access_web_object("button(locator).text", locator)
148
+ access_web_object("button(locator).text", WebObjects::Button, locator)
146
149
  end
147
150
 
148
151
  # Platform method to click a button object.
149
152
  # @see Symbiont::Generators#button
150
153
  def click_button_for(locator)
151
- access_web_object("button(locator).click", locator)
154
+ action = check_for_css("button(locator)", locator)
155
+ access_web_object("#{action}.click", WebObjects::Button, locator)
152
156
  end
153
157
 
154
158
  # Platform method to check if button object exists.
155
159
  # @see Symbiont::Generators#button
156
160
  def check_button_for_existence(locator)
157
- access_web_object("button(locator).exists?", locator)
161
+ access_web_object("button(locator).exists?", WebObjects::Button, locator)
158
162
  end
159
163
 
160
164
  # Platform method to check if button object is visible.
161
165
  # @see Symbiont::Generators#button
162
166
  def check_button_for_visibility(locator)
163
- access_web_object("button(locator).visible?", locator)
167
+ access_web_object("button(locator).visible?", WebObjects::Button, locator)
164
168
  end
165
169
 
166
170
  # Platform method to check if button object is enabled.
167
171
  # @see Symbiont::Generators#button
168
172
  def check_button_for_enabled(locator)
169
- access_web_object("button(locator).enabled?", locator)
173
+ access_web_object("button(locator).enabled?", WebObjects::Button, locator)
170
174
  end
171
175
 
172
176
  # Platform method to return a text field object.
@@ -179,31 +183,31 @@ module Symbiont
179
183
  # Platform method to retrieve text from a text field object.
180
184
  # @see Symbiont::Generators#text_field
181
185
  def get_text_field_value_for(locator)
182
- access_web_object("text_field(locator).value", locator)
186
+ access_web_object("text_field(locator).value", WebObjects::TextField, locator)
183
187
  end
184
188
 
185
189
  # Platform method to enter text into a text field object.
186
190
  # @see Symbiont::Generators#text_field
187
191
  def set_text_field_value_for(locator, value)
188
- access_web_object("text_field(locator).set(value)", locator, value)
192
+ access_web_object("text_field(locator).set(value)", WebObjects::TextField, locator, value)
189
193
  end
190
194
 
191
195
  # Platform method to check if text field object exists.
192
196
  # @see Symbiont::Generators#text_field
193
197
  def check_text_field_for_existence(locator)
194
- access_web_object("text_field(locator).exists?", locator)
198
+ access_web_object("text_field(locator).exists?", WebObjects::TextField, locator)
195
199
  end
196
200
 
197
201
  # Platform method to check if text field object is visible.
198
202
  # @see Symbiont::Generators#text_field
199
203
  def check_text_field_for_visibility(locator)
200
- access_web_object("text_field(locator).visible?", locator)
204
+ access_web_object("text_field(locator).visible?", WebObjects::TextField, locator)
201
205
  end
202
206
 
203
207
  # Platform method to check if text field object is enabled.
204
208
  # @see Symbiont::Generators#text_field
205
209
  def check_text_field_for_enabled(locator)
206
- access_web_object("text_field(locator).enabled?", locator)
210
+ access_web_object("text_field(locator).enabled?", WebObjects::TextField, locator)
207
211
  end
208
212
 
209
213
  # Platform method to return a select list object.
@@ -216,37 +220,37 @@ module Symbiont
216
220
  # Platform method to retrieve the text of the current selection from a select list object.
217
221
  # @see Symbiont::Generators#select_list
218
222
  def get_select_list_item_for(locator)
219
- access_web_object("select_list(locator).selected_options[0].text", locator)
223
+ access_web_object("select_list(locator).selected_options[0].text", WebObjects::SelectList, locator)
220
224
  end
221
225
 
222
226
  # Platform method to retrieve the value of the current selection from a select list object.
223
227
  # @see Symbiont::Generators#select_list
224
228
  def get_select_list_value_for(locator)
225
- access_web_object("select_list(locator).value", locator)
229
+ access_web_object("select_list(locator).value", WebObjects::SelectList, locator)
226
230
  end
227
231
 
228
232
  # Platform method to set the value of a select list object.
229
233
  # @see Symbiont::Generators#select_list
230
234
  def set_select_list_value_for(locator, value)
231
- access_web_object("select_list(locator).select(value)", locator, value)
235
+ access_web_object("select_list(locator).select(value)", WebObjects::SelectList, locator, value)
232
236
  end
233
237
 
234
238
  # Platform method to check if select_list object exists.
235
239
  # @see Symbiont::Generators#select_list
236
240
  def check_select_list_for_existence(locator)
237
- access_web_object("select_list(locator).exists?", locator)
241
+ access_web_object("select_list(locator).exists?", WebObjects::SelectList, locator)
238
242
  end
239
243
 
240
244
  # Platform method to check if select list object is visible.
241
245
  # @see Symbiont::Generators#select_list
242
246
  def check_select_list_for_visibility(locator)
243
- access_web_object("select_list(locator).visible?", locator)
247
+ access_web_object("select_list(locator).visible?", WebObjects::SelectList, locator)
244
248
  end
245
249
 
246
250
  # Platform method to check if select list object is enabled.
247
251
  # @see Symbiont::Generators#select_list
248
252
  def check_select_list_for_enabled(locator)
249
- access_web_object("select_list(locator).enabled?", locator)
253
+ access_web_object("select_list(locator).enabled?", WebObjects::SelectList, locator)
250
254
  end
251
255
 
252
256
  # Platform method to return a checkbox object.
@@ -259,37 +263,37 @@ module Symbiont
259
263
  # Platform method to check if checkbox object exists.
260
264
  # @see Symbiont::Generators#checkbox
261
265
  def check_checkbox_for_existence(locator)
262
- access_web_object("checkbox(locator).exists?", locator)
266
+ access_web_object("checkbox(locator).exists?", WebObjects::CheckBox, locator)
263
267
  end
264
268
 
265
269
  # Platform method to check if checkbox object is visible.
266
270
  # @see Symbiont::Generators#checkbox
267
271
  def check_checkbox_for_visibility(locator)
268
- access_web_object("checkbox(locator).visible?", locator)
272
+ access_web_object("checkbox(locator).visible?", WebObjects::CheckBox, locator)
269
273
  end
270
274
 
271
275
  # Platform method to check if checkbox object is enabled.
272
276
  # @see Symbiont::Generators#checkbox
273
277
  def check_checkbox_for_enabled(locator)
274
- access_web_object("checkbox(locator).enabled?", locator)
278
+ access_web_object("checkbox(locator).enabled?", WebObjects::CheckBox, locator)
275
279
  end
276
280
 
277
281
  # Platform method to determine if a checkbox is checked.
278
282
  # @see Symbiont::Generators#checkbox
279
283
  def check_checkbox_for_checked(locator)
280
- access_web_object("checkbox(locator).set?", locator)
284
+ access_web_object("checkbox(locator).set?", WebObjects::CheckBox, locator)
281
285
  end
282
286
 
283
287
  # Platform method to check a checkbox object.
284
288
  # @see Symbiont::Generators#checkbox
285
289
  def check_checkbox_for(locator)
286
- access_web_object("checkbox(locator).set", locator)
290
+ access_web_object("checkbox(locator).set", WebObjects::CheckBox, locator)
287
291
  end
288
292
 
289
293
  # Platform method to uncheck a checkbox object.
290
294
  # @see Symbiont::Generators#checkbox
291
295
  def uncheck_checkbox_for(locator)
292
- access_web_object("checkbox(locator).clear", locator)
296
+ access_web_object("checkbox(locator).clear", WebObjects::CheckBox, locator)
293
297
  end
294
298
 
295
299
  # Platform method to return a radio object.
@@ -302,31 +306,31 @@ module Symbiont
302
306
  # Platform method to check if radio object exists.
303
307
  # @see Symbiont::Generators#radio
304
308
  def check_radio_for_existence(locator)
305
- access_web_object("radio(locator).exists?", locator)
309
+ access_web_object("radio(locator).exists?", WebObjects::Radio, locator)
306
310
  end
307
311
 
308
312
  # Platform method to check if radio object is visible.
309
313
  # @see Symbiont::Generators#radio
310
314
  def check_radio_for_visibility(locator)
311
- access_web_object("radio(locator).visible?", locator)
315
+ access_web_object("radio(locator).visible?", WebObjects::Radio, locator)
312
316
  end
313
317
 
314
318
  # Platform method to check if radio object is enabled.
315
319
  # @see Symbiont::Generators#radio
316
320
  def check_radio_for_enabled(locator)
317
- access_web_object("radio(locator).enabled?", locator)
321
+ access_web_object("radio(locator).enabled?", WebObjects::Radio, locator)
318
322
  end
319
323
 
320
324
  # Platform method to determine if a radio is selected.
321
325
  # @see Symbiont::Generators#radio
322
326
  def check_radio_for_selected(locator)
323
- access_web_object("radio(locator).set?", locator)
327
+ access_web_object("radio(locator).set?", WebObjects::Radio, locator)
324
328
  end
325
329
 
326
330
  # Platform method to select a radio object.
327
331
  # @see Symbiont::Generators#radio
328
332
  def select_radio_for(locator)
329
- access_web_object("radio(locator).set", locator)
333
+ access_web_object("radio(locator).set", WebObjects::Radio, locator)
330
334
  end
331
335
 
332
336
  # Platform method to return a table object.
@@ -339,13 +343,13 @@ module Symbiont
339
343
  # Platform method to check if table object exists.
340
344
  # @see Symbiont::Generators#table
341
345
  def check_table_for_existence(locator)
342
- access_web_object("table(locator).exists?", locator)
346
+ access_web_object("table(locator).exists?", WebObjects::Table, locator)
343
347
  end
344
348
 
345
349
  # Platform method to check if table object is visible.
346
350
  # @see Symbiont::Generators#table
347
351
  def check_table_for_visibility(locator)
348
- access_web_object("table(locator).visible?", locator)
352
+ access_web_object("table(locator).visible?", WebObjects::Table, locator)
349
353
  end
350
354
 
351
355
  # Platform method to return a table cell object.
@@ -358,19 +362,19 @@ module Symbiont
358
362
  # Platform method to check if table cell object exists.
359
363
  # @see Symbiont::Generators#cell
360
364
  def check_table_cell_for_existence(locator)
361
- access_web_object("td(locator).exists?", locator)
365
+ access_web_object("td(locator).exists?", WebObjects::TableCell, locator)
362
366
  end
363
367
 
364
368
  # Platform method to check if table cell object is visible.
365
369
  # @see Symbiont::Generators#cell
366
370
  def check_table_cell_for_visibility(locator)
367
- access_web_object("td(locator).visible?", locator)
371
+ access_web_object("td(locator).visible?", WebObjects::TableCell, locator)
368
372
  end
369
373
 
370
374
  # Platform method to get text of table cell object.
371
375
  # @see Symbiont::Generators#cell
372
376
  def get_table_cell_text_for(locator)
373
- access_web_object("td(locator).text", locator)
377
+ access_web_object("td(locator).text", WebObjects::TableCell, locator)
374
378
  end
375
379
 
376
380
  # Platform method to return a div object.
@@ -383,19 +387,19 @@ module Symbiont
383
387
  # Platform method to check if div object exists.
384
388
  # @see Symbiont::Generators#div
385
389
  def check_div_for_existence(locator)
386
- access_web_object("div(locator).exists?", locator)
390
+ access_web_object("div(locator).exists?", WebObjects::Div, locator)
387
391
  end
388
392
 
389
393
  # Platform method to check if div object is visible.
390
394
  # @see Symbiont::Generators#div
391
395
  def check_div_for_visibility(locator)
392
- access_web_object("div(locator).visible?", locator)
396
+ access_web_object("div(locator).visible?", WebObjects::Div, locator)
393
397
  end
394
398
 
395
399
  # Platform method to get text of div object.
396
400
  # @see Symbiont::Generators#div
397
401
  def get_div_text_for(locator)
398
- access_web_object("div(locator).text", locator)
402
+ access_web_object("div(locator).text", WebObjects::Div, locator)
399
403
  end
400
404
 
401
405
  # Platform method to return a span object.
@@ -408,19 +412,19 @@ module Symbiont
408
412
  # Platform method to check if span object exists.
409
413
  # @see Symbiont::Generators#span
410
414
  def check_span_for_existence(locator)
411
- access_web_object("span(locator).exists?", locator)
415
+ access_web_object("span(locator).exists?", WebObjects::Span, locator)
412
416
  end
413
417
 
414
418
  # Platform method to check if span object is visible.
415
419
  # @see Symbiont::Generators#span
416
420
  def check_span_for_visibility(locator)
417
- access_web_object("span(locator).visible?", locator)
421
+ access_web_object("span(locator).visible?", WebObjects::Span, locator)
418
422
  end
419
423
 
420
424
  # Platform method to get text of span object.
421
425
  # @see Symbiont::Generators#span
422
426
  def get_span_text_for(locator)
423
- access_web_object("span(locator).text", locator)
427
+ access_web_object("span(locator).text", WebObjects::Span, locator)
424
428
  end
425
429
 
426
430
  private
@@ -434,6 +438,7 @@ module Symbiont
434
438
  # @return [Object] the web object identified by the action
435
439
  def reference_web_object(action, object_type, locator)
436
440
  enclosers = locator.delete(:frame)
441
+ locator = object_type.provide_locator_for(locator)
437
442
  web_object = @browser.instance_eval "#{enclosed_by(enclosers)}#{action}"
438
443
  object_type.new(web_object)
439
444
  end
@@ -447,11 +452,16 @@ module Symbiont
447
452
  # @param [String] value any specific information that must be sent to the
448
453
  # web object
449
454
  # @return [Any] the information or object returned by the action
450
- def access_web_object(action, locator, value=nil)
455
+ def access_web_object(action, object_type, locator, value=nil)
451
456
  enclosers = locator.delete(:frame)
457
+ locator = object_type.provide_locator_for(locator)
452
458
  @browser.instance_eval "#{enclosed_by(enclosers)}#{action}"
453
459
  end
454
460
 
461
+ def check_for_css(action, locator)
462
+ locator[:css] ? "element(locator)" : action
463
+ end
464
+
455
465
  # This method is used to wrap a web object locator within the locator for an
456
466
  # enclosing web object. Currently the only enclosing objects this makes sense
457
467
  # for are iframes and frames.
@@ -1,3 +1,3 @@
1
1
  module Symbiont
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -74,6 +74,23 @@ module Symbiont
74
74
  def wait_until(timeout, message=nil, &block)
75
75
  Object::Watir::Wait.until(timeout, message, &block)
76
76
  end
77
+
78
+ def self.usable_selectors
79
+ [:id, :name, :xpath, :class, :index]
80
+ end
81
+
82
+ def self.selector_mapping
83
+ {}
84
+ end
85
+
86
+ def self.provide_locator_for(locator)
87
+ locator.each do |key, value|
88
+ how, what = locator.keys.first, locator.values.first
89
+ return how => what if usable_selectors.include? how
90
+ return selector_mapping[how] => what if selector_mapping[how]
91
+ return nil => what
92
+ end
93
+ end
77
94
  end # class: WebObject
78
95
 
79
96
  end # module: WebObjects
@@ -2,10 +2,15 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class Button < WebObject
5
-
5
+
6
+ def self.usable_selectors
7
+ super + [:value, :text, :css]
8
+ end
9
+
6
10
  end # class: Button
7
11
 
8
12
  ::Symbiont::WebObjects.class_for_type[:submit] = ::Symbiont::WebObjects::Button
9
13
  ::Symbiont::WebObjects.class_for_type[:button] = ::Symbiont::WebObjects::Button
14
+
10
15
  end # module: WebObjects
11
16
  end # module: Symbiont
@@ -2,7 +2,15 @@ module Symbiont
2
2
  module WebObjects
3
3
 
4
4
  class Link < WebObject
5
-
5
+
6
+ def self.usable_selectors
7
+ super + [:href, :text, :title, :css]
8
+ end
9
+
10
+ def self.selector_mapping
11
+ super.merge({:link => :text, :link_text => :text})
12
+ end
13
+
6
14
  end # class: Link
7
15
 
8
16
  ::Symbiont::WebObjects.class_for_tag[:a] = ::Symbiont::WebObjects::Link
@@ -3,6 +3,14 @@ require 'spec_helper'
3
3
  describe "Web Objects" do
4
4
  let(:watir_browser) { mock_browser_for_watir }
5
5
  let(:watir_definition) { ::Symbiont::WebObjects::WebObject.new(watir_browser) }
6
+ let(:link) { Symbiont::WebObjects::Link }
7
+
8
+ it "should return no key for an unrecognized locator" do
9
+ [:invalid].each do |s|
10
+ locator = link.provide_locator_for s => 'value'
11
+ locator.keys.first.should == nil
12
+ end
13
+ end
6
14
 
7
15
  it "should retrieve the value of an attribute" do
8
16
  watir_browser.should_receive(:attribute_value).and_return(true)
@@ -3,6 +3,21 @@ require 'spec_helper'
3
3
  describe Symbiont::WebObjects::Button do
4
4
  describe "implementation" do
5
5
  let(:button_object) { double('button_object') }
6
+ let(:button) { Symbiont::WebObjects::Button }
7
+
8
+ it "should reference standard usable selectors" do
9
+ [:class, :id, :name, :index, :xpath].each do |s|
10
+ locator = button.provide_locator_for s => 'value'
11
+ locator.keys.first.should == s
12
+ end
13
+ end
14
+
15
+ it "should reference specific usable selectors" do
16
+ [:value, :text].each do |s|
17
+ locator = button.provide_locator_for s => 'value'
18
+ locator.keys.first.should == s
19
+ end
20
+ end
6
21
 
7
22
  it "should register with a submit type" do
8
23
  ::Symbiont::WebObjects.get_class_for(:input, :submit).should == ::Symbiont::WebObjects::Button
@@ -3,6 +3,28 @@ require 'spec_helper'
3
3
  describe Symbiont::WebObjects::Link do
4
4
  describe "implementation" do
5
5
  let(:link_object) { double('link_object') }
6
+ let(:link) { Symbiont::WebObjects::Link }
7
+
8
+ it "should reference standard usable selectors" do
9
+ [:class, :id, :name, :index, :xpath].each do |s|
10
+ locator = link.provide_locator_for s => 'value'
11
+ locator.keys.first.should == s
12
+ end
13
+ end
14
+
15
+ it "should reference specific usable selectors" do
16
+ [:href, :text, :title, :css].each do |s|
17
+ locator = link.provide_locator_for s => 'value'
18
+ locator.keys.first.should == s
19
+ end
20
+ end
21
+
22
+ it "should reference mappable selectors" do
23
+ [:link, :link_text].each do |s|
24
+ locator = link.provide_locator_for s => 'value'
25
+ locator.keys.first.should == :text
26
+ end
27
+ end
6
28
 
7
29
  it "should register with an anchor tag" do
8
30
  ::Symbiont::WebObjects.get_class_for(:a).should == ::Symbiont::WebObjects::Link
@@ -3,6 +3,13 @@ require 'spec_helper'
3
3
  describe Symbiont::WebObjects::SelectList do
4
4
  describe "implementation" do
5
5
  let(:select_list_object) { double('select_list_object') }
6
+ let(:select_list) { Symbiont::WebObjects::SelectList }
7
+ it "should reference standard usable selectors" do
8
+ [:class, :id, :name, :index, :xpath].each do |s|
9
+ locator = select_list.provide_locator_for s => 'value'
10
+ locator.keys.first.should == s
11
+ end
12
+ end
6
13
 
7
14
  it "should register with a select list tag" do
8
15
  ::Symbiont::WebObjects.get_class_for(:select).should == ::Symbiont::WebObjects::SelectList
@@ -4,6 +4,14 @@ describe Symbiont::WebObjects::TextField do
4
4
  describe "implementation" do
5
5
  let(:text_field_object) { double('text_field_object') }
6
6
  let(:text_field_definition) { ::Symbiont::WebObjects::TextField.new(text_field_object) }
7
+ let(:text_field) { Symbiont::WebObjects::TextField }
8
+
9
+ it "should reference standard usable selectors" do
10
+ [:class, :id, :name, :index, :xpath].each do |s|
11
+ locator = text_field.provide_locator_for s => 'value'
12
+ locator.keys.first.should == s
13
+ end
14
+ end
7
15
 
8
16
  it "should get the value of a text field" do
9
17
  text_field_object.should_receive(:value).and_return("testing")
data/specs/button.feature CHANGED
@@ -41,3 +41,4 @@ Feature: Ability to Support Button Web Objects
41
41
  | index |
42
42
  | value |
43
43
  | text |
44
+ | css |
@@ -23,6 +23,10 @@ class SimpleObjectPage
23
23
  link :avengersIndex, {id: "avengersID", index: 0}
24
24
  link :avengersText, text: "Avengers Assemble"
25
25
  link :avengersHref, href: "success_1"
26
+ link :avengersLink, link: "Avengers Assemble"
27
+ link :avengersLinkText, link_text: "Avengers Assemble"
28
+ link :avengersTitle, title: "Click to Assemble"
29
+ link :avengersCSS, css: "#avengersID"
26
30
 
27
31
  button :clickmeID, id: "clickmeID"
28
32
  button :clickmeName, name: "clickmeName"
@@ -31,6 +35,7 @@ class SimpleObjectPage
31
35
  button :clickmeIndex, {id: "clickmeID", index: 0}
32
36
  button :clickmeValue, value: "Click Me"
33
37
  button :clickmeText, text: "Click Me"
38
+ button :clickmeCSS, css: "#clickmeID"
34
39
 
35
40
  button :cantClickMeID, id: "cantclickmeID"
36
41
 
data/specs/link.feature CHANGED
@@ -28,11 +28,15 @@ Feature: Ability to Support Link Web Objects
28
28
  Then the first success page appears
29
29
 
30
30
  Scenarios:
31
- | locator |
32
- | id |
33
- | name |
34
- | class |
35
- | xpath |
36
- | index |
37
- | text |
38
- | href |
31
+ | locator |
32
+ | css |
33
+ | id |
34
+ | name |
35
+ | class |
36
+ | xpath |
37
+ | index |
38
+ | title |
39
+ | text |
40
+ | href |
41
+ | link |
42
+ | link_text |
@@ -12,6 +12,7 @@ When (/^the click me button on the object test page is clicked by "([^"]*)"$/) d
12
12
  @page.clickmeIndex if locator == "index"
13
13
  @page.clickmeValue if locator == "value"
14
14
  @page.clickmeText if locator == "text"
15
+ @page.clickmeCSS if locator == "css"
15
16
  end
16
17
 
17
18
  Then (/^the click me button should exist$/) do
@@ -10,13 +10,17 @@ end
10
10
 
11
11
  When (/^the avengers link on the object test page is clicked by "([^"]*)"$/) do |locator|
12
12
  @page = SimpleObjectPage.new(@browser, true)
13
+ @page.avengersCSS if locator == "css"
13
14
  @page.avengersID if locator == "id"
14
15
  @page.avengersName if locator == "name"
15
16
  @page.avengersClass if locator == "class"
16
17
  @page.avengersXPath if locator == "xpath"
17
18
  @page.avengersIndex if locator == "index"
19
+ @page.avengersTitle if locator == "title"
18
20
  @page.avengersText if locator == "text"
19
21
  @page.avengersHref if locator == "href"
22
+ @page.avengersLink if locator == "link"
23
+ @page.avengersLinkText if locator == "link_text"
20
24
  end
21
25
 
22
26
  Then (/^the database app link should exist$/) do
data/symbiont.gemspec CHANGED
@@ -12,9 +12,10 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = gem.description
13
13
  gem.description = "An endosymbiotic facultative library for web application testing."
14
14
 
15
- gem.add_development_dependency "rspec", "2.10.0"
15
+ gem.add_development_dependency "rspec", "2.11.0"
16
16
  gem.add_development_dependency "simplecov", "0.6.4"
17
17
  gem.add_development_dependency "yard", "0.8.2.1"
18
+ gem.add_development_dependency "cucumber", "1.2.1"
18
19
 
19
20
  gem.add_runtime_dependency "watir-webdriver", "0.6.1"
20
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symbiont
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-15 00:00:00.000000000 Z
12
+ date: 2012-08-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.10.0
21
+ version: 2.11.0
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.10.0
29
+ version: 2.11.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: simplecov
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.8.2.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: cucumber
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.1
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - '='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.1
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: watir-webdriver
64
80
  requirement: !ruby/object:Gem::Requirement