SimpliTest 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -21
  3. data/SimpliTest.gemspec +42 -42
  4. data/bin/SimpliTest +22 -22
  5. data/lib/SimpliTest.rb +2 -2
  6. data/lib/SimpliTest/cli/main.rb +333 -333
  7. data/lib/SimpliTest/config/configuration.rb +107 -107
  8. data/lib/SimpliTest/config/directory_paths.rb +36 -36
  9. data/lib/SimpliTest/config/environment.rb +67 -67
  10. data/lib/SimpliTest/config/local_environment.rb +20 -20
  11. data/lib/SimpliTest/config/profiles/chrome.rb +18 -18
  12. data/lib/SimpliTest/config/profiles/firefox.rb +14 -14
  13. data/lib/SimpliTest/config/profiles/internet_explorer.rb +11 -11
  14. data/lib/SimpliTest/config/profiles/phantom.rb +9 -9
  15. data/lib/SimpliTest/config/profiles/phantom_debug.rb +12 -12
  16. data/lib/SimpliTest/config/profiles/selenium.rb +13 -13
  17. data/lib/SimpliTest/config/screen_size.rb +25 -25
  18. data/lib/SimpliTest/config/steps.rb +8 -8
  19. data/lib/SimpliTest/helpers/data_validation.rb +60 -60
  20. data/lib/SimpliTest/helpers/file.rb +38 -38
  21. data/lib/SimpliTest/helpers/project_setup.rb +186 -186
  22. data/lib/SimpliTest/helpers/step_helpers/custom_chrome_helpers.rb +14 -14
  23. data/lib/SimpliTest/helpers/step_helpers/custom_date_helpers.rb +64 -64
  24. data/lib/SimpliTest/helpers/step_helpers/custom_form_helpers.rb +66 -66
  25. data/lib/SimpliTest/helpers/step_helpers/custom_phantomjs_helpers.rb +49 -49
  26. data/lib/SimpliTest/helpers/step_helpers/custom_selenium_helpers.rb +41 -41
  27. data/lib/SimpliTest/helpers/step_helpers/html_selectors_helpers.rb +154 -154
  28. data/lib/SimpliTest/helpers/step_helpers/navigation_helpers.rb +206 -206
  29. data/lib/SimpliTest/helpers/step_helpers/tolerance_for_sync_issues.rb +38 -38
  30. data/lib/SimpliTest/helpers/step_helpers/within_helpers.rb +6 -6
  31. data/lib/SimpliTest/helpers/windows_ui.rb +51 -51
  32. data/lib/SimpliTest/steps/debugging_steps.rb +19 -19
  33. data/lib/SimpliTest/steps/form_steps.rb +348 -352
  34. data/lib/SimpliTest/steps/form_verification_steps.rb +189 -189
  35. data/lib/SimpliTest/steps/navigation_steps.rb +58 -47
  36. data/lib/SimpliTest/steps/scoper.rb +42 -42
  37. data/lib/SimpliTest/steps/verification_steps.rb +306 -306
  38. data/lib/SimpliTest/tasks/document.rb +169 -169
  39. data/lib/SimpliTest/tasks/examples.rb +18 -18
  40. data/lib/SimpliTest/tasks/testinstall.rb +5 -5
  41. data/lib/SimpliTest/templates/NewSimpliTestProject/Readme.txt +4 -4
  42. data/lib/SimpliTest/templates/NewSimpliTestProject/cucumber.yml +26 -26
  43. data/lib/SimpliTest/templates/NewSimpliTestProject/documentation/step_definitions.html +88 -87
  44. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/RegressionTests/HelloWorld.feature +3 -3
  45. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/SmokeTest/HelloWorld.feature +3 -3
  46. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/accessibilityTests/HelloWorld.feature +3 -3
  47. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/environments.yml +10 -10
  48. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/pages.yml +26 -26
  49. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/selectors.yml +44 -44
  50. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/settings.yml +26 -26
  51. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/env.rb +33 -33
  52. data/lib/SimpliTest/templates/NewSimpliTestProject/license.txt +29 -29
  53. data/lib/SimpliTest/templates/document/css/style.css +28 -28
  54. data/lib/SimpliTest/templates/document/index.html +60 -60
  55. data/lib/version.rb +3 -3
  56. metadata +4 -4
@@ -1,42 +1,42 @@
1
- require 'axe/cucumber/step_definitions'
2
-
3
- # :nocov:
4
- # Single-line step scoper
5
- When /^(.*) within(?: the| an?)? (.*)$/ do |step_def, parent|
6
- selector, selector_type = selector_for(parent)
7
- patiently do
8
- if selector_type == 'xpath'
9
- within(:xpath, selector) do
10
- step step_def
11
- end
12
- elsif selector_type == 'css'
13
- within(:css, selector) do
14
- step step_def
15
- end
16
- else
17
- with_scope(parent) { step step_def }
18
- end
19
- end
20
- end
21
-
22
- # Multi-line step scoper
23
- When /^(.*) within(?: the| an?)? (.*):$/ do |step_def, parent, table_or_string|
24
- selector, selector_type = selector_for(parent)
25
- patiently do
26
- if selector_type == 'xpath'
27
- within(:xpath, xpath) do
28
- step "#{step_def}:", table_or_string
29
- end
30
- else
31
- with_scope(parent) { step "#{step_def}:", table_or_string }
32
- end
33
- end
34
- end
35
- # :nocov:
36
-
37
- # Execute step in the last opened window
38
- When /^(.*) in the new window$/ do |step_def|
39
- change_window 'last'
40
- step step_def
41
- end
42
-
1
+ require 'axe/cucumber/step_definitions'
2
+
3
+ # :nocov:
4
+ # Single-line step scoper
5
+ When /^(.*) within(?: the| an?)? (.*)$/ do |step_def, parent|
6
+ selector, selector_type = selector_for(parent)
7
+ patiently do
8
+ if selector_type == 'xpath'
9
+ within(:xpath, selector) do
10
+ step step_def
11
+ end
12
+ elsif selector_type == 'css'
13
+ within(:css, selector) do
14
+ step step_def
15
+ end
16
+ else
17
+ with_scope(parent) { step step_def }
18
+ end
19
+ end
20
+ end
21
+
22
+ # Multi-line step scoper
23
+ When /^(.*) within(?: the| an?)? (.*):$/ do |step_def, parent, table_or_string|
24
+ selector, selector_type = selector_for(parent)
25
+ patiently do
26
+ if selector_type == 'xpath'
27
+ within(:xpath, xpath) do
28
+ step "#{step_def}:", table_or_string
29
+ end
30
+ else
31
+ with_scope(parent) { step "#{step_def}:", table_or_string }
32
+ end
33
+ end
34
+ end
35
+ # :nocov:
36
+
37
+ # Execute step in the last opened window
38
+ When /^(.*) in the new window$/ do |step_def|
39
+ change_window 'last'
40
+ step step_def
41
+ end
42
+
@@ -1,306 +1,306 @@
1
-
2
- #************************ NAVIGATION *********************************************
3
-
4
- #Example: Then I should be redirected to the "congratulations" page
5
- Then /^I should be redirected to the "(.*)" page$/ do |page_name|
6
- definition = <<-def
7
- I should be on the "#{page_name}" page
8
- def
9
- step definition
10
- end
11
-
12
- #Example: Then I should be redirected to the "Results" page with some parameters
13
- Then(/^I should be redirected to the "(.*?)" page with some parameters$/) do |page_name|
14
- sleep SimpliTest.wait_for_page_load
15
- target_url = without_trailing_slash(path_to(page_name)).downcase
16
- patiently do
17
- current_url = without_trailing_slash page.current_url.downcase
18
- if current_url.index(target_url)
19
- current_url.index(target_url).should_not be_nil
20
- else
21
- current_url.should == target_url
22
- end
23
- end
24
- end
25
-
26
- #Example: Then I should be on the "congratulations" page
27
- Then /^(?:|I )should be on the "(.*)" page$/ do |page_name|
28
- sleep SimpliTest.wait_for_page_load
29
- target_url, current_url = comparable_urls_for(path_to(page_name), page.current_url)
30
- current_url.should == target_url
31
- end
32
-
33
-
34
- #************************ END NAVIGATION *****************************************
35
-
36
-
37
- #************************ LABELS AND TEXT ****************************************
38
-
39
-
40
- #Example: And I should see "Great, you can click links!"
41
- Then /^(?:|I )should see "(.*)"$/ do |text|
42
- patiently { page.should have_content(text) }
43
- end
44
-
45
-
46
- #Example: And I should not see "some bla-bla"
47
- Then /^(?:|I )should not see "(.*)"$/ do |text|
48
- patiently { page.should have_no_content(text) }
49
- end
50
-
51
- #Example: Then I should see /great/i
52
- Then /^(?:|I )should see \/([^\/]*)\/([imxo])?$/ do |regexp,flags|
53
- regexp_opts = [regexp,flags].compact
54
- regexp = Regexp.new(*regexp_opts)
55
- patiently { page.should have_xpath('//*', :text => regexp) }
56
- end
57
-
58
- #Example: Then I should not see /bla-bla/i
59
- Then /^(?:|I )should not see \/([^\/]*)\/([imxo])?$/ do |regexp,flags|
60
- regexp_opts = [regexp,flags].compact
61
- regexp = Regexp.new(*regexp_opts)
62
- patiently { page.should have_no_xpath('//*', :text => regexp) }
63
- end
64
-
65
- #Example: Then I should see all of the texts: <pass a table with text values>
66
- Then /^I should see all of the texts:?$/ do |table|
67
- table.raw.each do |text|
68
- step "I should see \"#{text[0]}\""
69
- end
70
- end
71
-
72
- #TODO: No test case for this
73
- #TODO: This step is redundant, deprecate it
74
- #Example: Then I should see the "ZipInlineFeedback" text as "Hello"
75
- #Example: Not yet implemented
76
- Then /^I should see the "(.*?)" text as "(.*)"$/ do |locator, text|
77
- patiently do
78
- element = get_element_from(locator, false)
79
- element.text.should == text
80
- end
81
- end
82
-
83
-
84
- #************************ END LABELS AND TEXT ************************************
85
-
86
-
87
- #************************ BUTTONS AND LINKS **************************************
88
-
89
- #Example: Then I should see the "Submit" button
90
- Then /^(?: |I )should see the "(.*)"(?: button| link)$/ do |link_or_button_text|
91
- patiently do
92
- selector, selector_type = selector_for(link_or_button_text)
93
- if selector_type == 'other'
94
- begin
95
- should have_link(link_or_button_text)
96
- rescue RSpec::Expectations::ExpectationNotMetError
97
- should have_button(link_or_button_text)
98
- end
99
- else
100
- find(selector_type.to_sym, selector)
101
- end
102
- end
103
- end
104
-
105
-
106
- #TODO: the double patiently block makes me sad
107
- #Example: And I should not see the "Click Me" link
108
- Then /^(?: |I )should not see the "(.*)"(?: button| link)$/ do |button_or_link_text|
109
- validate_absence_of button_or_link_text
110
- end
111
-
112
- #Example: Then I should see a link that points to "http://www.google.com/"
113
- Then /^I should see an? link that points to "([^"]*)"$/ do |href_destination|
114
- page.should have_xpath("//a[@href='#{href_destination}']")
115
- end
116
-
117
- #Example: Then the 5th instance of "Page1PaginationLinks" should be disabled
118
- Then /^the (first|last|[0-9]+(?:th|st|rd|nd)) instance of "(.*?)" should be disabled$/ do |index, button_or_link|
119
- selector, selector_type = selector_for(button_or_link)
120
- index = numerize index
121
- if selector_type == 'css'
122
- elements = all(:css, selector)
123
- else
124
- raise "Only CSS Selectors are supported. Please add a Valid CSS Selector in selectors.yml"
125
- end
126
- elements[index].should be_disabled if elements
127
- end
128
-
129
- #Example: Then I should see that all asset references on the page are valid
130
- Then /^I should see that all asset references on the page are valid$/ do
131
- patiently do
132
- document = parse_dom_tree(current_url)
133
- valid_assets_links_from(document).each do |link|
134
- validate_response_from(current_url, link)
135
- end
136
- end
137
- end
138
-
139
- #Example: And I should see that all links on the page are valid
140
- Then /^I should see that all links on the page are valid$/ do
141
- document = parse_dom_tree(current_url)
142
- links_on(document).each do |link|
143
- validate_response_from(current_url, link)
144
- end
145
- end
146
-
147
-
148
- #************************ BUTTONS AND LINKS **************************************
149
-
150
- #************************ PAGINATION **************************************
151
-
152
- #Example: Then I should be on page 2
153
- Then /^I should be on page (\d+)$/ do |page_number|
154
- pagination_links_for(page_number).collect(&:disabled?).uniq.should == [true]
155
- end
156
-
157
- #************************ PAGINATION **************************************
158
-
159
-
160
-
161
- #************************ LIST/ ERROR MESSAGES ***********************************
162
-
163
- #TODO: Add a test
164
- #Example: Then I should see the following errors: Accepts Gherkin Table
165
- #Example: Not yet implemented
166
- Then /^I should see the following(?: errors| list):$/ do |table|
167
- column_header, *list = table.raw
168
- list.flatten.each do |message|
169
- patiently { page.should have_content(message) }
170
- end
171
- end
172
-
173
-
174
- #************************ END LIST/ ERROR MESSAGES *******************************
175
-
176
-
177
- #************************ TAGS ***************************************************
178
-
179
- #Example: Then I should see a "td" tag around "bla"
180
- Then /^I should see an? "([^"]*)" tag around the text "([^"]*)"$/ do |tag_name, text|
181
- page.should have_xpath("//#{tag_name}[text()=\"#{text}\"]")
182
- end
183
-
184
- #Example: Then I should see a "div" with "id" of "ui-datepicker-div"
185
- Then /^I should see an? "([^"]*)" with "([^"]*)" of "([^"]*)"$/ do |tag_name, attribute_name, attribute_value|
186
- page.should have_xpath("//#{tag_name}[@#{attribute_name}=\"#{attribute_value}\"]")
187
- end
188
-
189
-
190
- #************************ END TAGS ***********************************************
191
-
192
-
193
- #************************ IMAGES *************************************************
194
-
195
- #TODO: Add Examples
196
- #Example: Then I should see the image "Image1.jpg"
197
- Then /^I should see the image "([^"]*)"$/ do |image_name|
198
- page.should have_xpath("//img[contains(@src, \"#{image_name}\")]")
199
- end
200
-
201
- #Example: Then I should see all of the images: <accepts a list of image names(src)>
202
- Then /^I should see all of the images:?$/ do |table|
203
- table.raw.each do |text|
204
- step "I should see the image \"#{text[0]}\""
205
- end
206
- end
207
-
208
- #Example: Then I should see text "some alt text" as alt text for ImageSelector
209
- Then /^(?:|I )should see text "(.*)" as alt text for (.*)$/ do |alt_text, locator|
210
- selector, selector_type = selector_for(locator)
211
- if selector_type == 'xpath'
212
- patiently { page.should have_xpath("#{selector}[@alt='#{alt_text}']") }
213
- elsif selector_type == 'css'
214
- patiently { page.should have_css("#{selector}[alt='#{alt_text}']") }
215
- else
216
- patiently { page.should have_xpath("//img[contains(@src, '#{unquoted(selector)}')][@alt='#{alt_text}']") }
217
- end
218
- end
219
-
220
-
221
- #************************ END IMAGES *********************************************
222
-
223
-
224
- #************************ AUDIO **************************************************
225
-
226
- #TODO: Add Examples
227
- #Example: Then I should see the HTML5 audio source "Audio.mp3"
228
- Then /^I should see the HTML5 audio source "([^"]*)"$/ do |audio_name|
229
- page.should have_xpath("//audio[contains(@src, \"#{audio_name}\")] | //audio/source[contains(@src, \"#{audio_name}\")]")
230
- end
231
- #Example: Then I should see the HTML5 audio sources: <Accepts a list of audio file names>
232
- Then /^I should see all of the HTML5 audio sources:?$/ do |table|
233
- table.raw.each do |text|
234
- step "I should see the HTML5 audio source \"#{text[0]}\""
235
- end
236
- end
237
-
238
-
239
- #************************ END AUDIO **********************************************
240
-
241
-
242
- #************************ VIDEO **************************************************
243
-
244
- #TODO: Add Examples
245
- #Example: Then I should see the HTML5 video source "video1.mp4"
246
- Then /^I should see the HTML5 video source "([^"]*)"$/ do |video_name|
247
- page.should have_xpath("//video[contains(@src, \"#{video_name}\")] | //video/source[contains(@src, \"#{video_name}\")]")
248
- end
249
-
250
- #Example: Then I should see the HTML5 video sources: <accepts a table of video sources>
251
- Then /^I should see all of the HTML5 video sources:$/ do |table|
252
- table.raw.each do |text|
253
- step "I should see the HTML5 video source \"#{text[0]}\""
254
- end
255
- end
256
-
257
-
258
- #************************ VIDEO **************************************************
259
-
260
-
261
- #************************ OTHER ELEMENTS *****************************************
262
-
263
-
264
- #TODO: Hate the language here, need to fix this
265
- #Example: Then I should see 2 elements kind of table's header
266
- Then /^I should see (\d+) elements? kind of (.+)$/ do |count, locator|
267
- selector, xpath = selector_for(locator)
268
- patiently do
269
- actual_count = all(selector).count
270
- count = count.to_i
271
- actual_count.should eq(count)
272
- end
273
- end
274
-
275
- #Example: And I should not see elements kind of paragraphs
276
- Then /^I should not see elements? kind of (.+)$/ do |locator|
277
- patiently { page.should_not have_css(selector_for(locator).first) }
278
- end
279
-
280
-
281
- #************************ END OTHER ELEMENTS *************************************
282
-
283
-
284
-
285
- #Example: Not Implemented yet
286
- Then /^I should see "(.*?)" as "(.*?)" value$/ do |arg1, arg2|
287
- pending # express the regexp above with the code you wish you had
288
- end
289
-
290
-
291
- #*********************** SELECTOR SECTION ********************************
292
-
293
-
294
- #Example: Then I should see the correct "MedicareGovHeader"
295
- Then /^I should see the correct "(.*)"$/ do |section|
296
- locators = selectors_from_section(section)
297
- locators.each do |locator|
298
- if is_css?(locator)
299
- should have_css(selector_from(locator).first)
300
- elsif is_xpath?(locator)
301
- should have_xpath(selector_from(locator).first)
302
- else
303
- raise "Could not determine selector type for #{selector}"
304
- end
305
- end
306
- end
1
+
2
+ #************************ NAVIGATION *********************************************
3
+
4
+ #Example: Then I should be redirected to the "congratulations" page
5
+ Then /^I should be redirected to the "(.*)" page$/ do |page_name|
6
+ definition = <<-def
7
+ I should be on the "#{page_name}" page
8
+ def
9
+ step definition
10
+ end
11
+
12
+ #Example: Then I should be redirected to the "Results" page with some parameters
13
+ Then(/^I should be redirected to the "(.*?)" page with some parameters$/) do |page_name|
14
+ sleep SimpliTest.wait_for_page_load
15
+ target_url = without_trailing_slash(path_to(page_name)).downcase
16
+ patiently do
17
+ current_url = without_trailing_slash page.current_url.downcase
18
+ if current_url.index(target_url)
19
+ current_url.index(target_url).should_not be_nil
20
+ else
21
+ current_url.should == target_url
22
+ end
23
+ end
24
+ end
25
+
26
+ #Example: Then I should be on the "congratulations" page
27
+ Then /^(?:|I )should be on the "(.*)" page$/ do |page_name|
28
+ sleep SimpliTest.wait_for_page_load
29
+ target_url, current_url = comparable_urls_for(path_to(page_name), page.current_url)
30
+ current_url.should == target_url
31
+ end
32
+
33
+
34
+ #************************ END NAVIGATION *****************************************
35
+
36
+
37
+ #************************ LABELS AND TEXT ****************************************
38
+
39
+
40
+ #Example: And I should see "Great, you can click links!"
41
+ Then /^(?:|I )should see "(.*)"$/ do |text|
42
+ patiently { page.should have_content(text) }
43
+ end
44
+
45
+
46
+ #Example: And I should not see "some bla-bla"
47
+ Then /^(?:|I )should not see "(.*)"$/ do |text|
48
+ patiently { page.should have_no_content(text) }
49
+ end
50
+
51
+ #Example: Then I should see /great/i
52
+ Then /^(?:|I )should see \/([^\/]*)\/([imxo])?$/ do |regexp,flags|
53
+ regexp_opts = [regexp,flags].compact
54
+ regexp = Regexp.new(*regexp_opts)
55
+ patiently { page.should have_xpath('//*', :text => regexp) }
56
+ end
57
+
58
+ #Example: Then I should not see /bla-bla/i
59
+ Then /^(?:|I )should not see \/([^\/]*)\/([imxo])?$/ do |regexp,flags|
60
+ regexp_opts = [regexp,flags].compact
61
+ regexp = Regexp.new(*regexp_opts)
62
+ patiently { page.should have_no_xpath('//*', :text => regexp) }
63
+ end
64
+
65
+ #Example: Then I should see all of the texts: <pass a table with text values>
66
+ Then /^I should see all of the texts:?$/ do |table|
67
+ table.raw.each do |text|
68
+ step "I should see \"#{text[0]}\""
69
+ end
70
+ end
71
+
72
+ #TODO: No test case for this
73
+ #TODO: This step is redundant, deprecate it
74
+ #Example: Then I should see the "ZipInlineFeedback" text as "Hello"
75
+ #Example: Not yet implemented
76
+ Then /^I should see the "(.*?)" text as "(.*)"$/ do |locator, text|
77
+ patiently do
78
+ element = get_element_from(locator, false)
79
+ element.text.should == text
80
+ end
81
+ end
82
+
83
+
84
+ #************************ END LABELS AND TEXT ************************************
85
+
86
+
87
+ #************************ BUTTONS AND LINKS **************************************
88
+
89
+ #Example: Then I should see the "Submit" button
90
+ Then /^(?: |I )should see the "(.*)"(?: button| link)$/ do |link_or_button_text|
91
+ patiently do
92
+ selector, selector_type = selector_for(link_or_button_text)
93
+ if selector_type == 'other'
94
+ begin
95
+ should have_link(link_or_button_text)
96
+ rescue RSpec::Expectations::ExpectationNotMetError
97
+ should have_button(link_or_button_text)
98
+ end
99
+ else
100
+ find(selector_type.to_sym, selector)
101
+ end
102
+ end
103
+ end
104
+
105
+
106
+ #TODO: the double patiently block makes me sad
107
+ #Example: And I should not see the "Click Me" link
108
+ Then /^(?: |I )should not see the "(.*)"(?: button| link)$/ do |button_or_link_text|
109
+ validate_absence_of button_or_link_text
110
+ end
111
+
112
+ #Example: Then I should see a link that points to "http://www.google.com/"
113
+ Then /^I should see an? link that points to "([^"]*)"$/ do |href_destination|
114
+ page.should have_xpath("//a[@href='#{href_destination}']")
115
+ end
116
+
117
+ #Example: Then the 5th instance of "Page1PaginationLinks" should be disabled
118
+ Then /^the (first|last|[0-9]+(?:th|st|rd|nd)) instance of "(.*?)" should be disabled$/ do |index, button_or_link|
119
+ selector, selector_type = selector_for(button_or_link)
120
+ index = numerize index
121
+ if selector_type == 'css'
122
+ elements = all(:css, selector)
123
+ else
124
+ raise "Only CSS Selectors are supported. Please add a Valid CSS Selector in selectors.yml"
125
+ end
126
+ elements[index].should be_disabled if elements
127
+ end
128
+
129
+ #Example: Then I should see that all asset references on the page are valid
130
+ Then /^I should see that all asset references on the page are valid$/ do
131
+ patiently do
132
+ document = parse_dom_tree(current_url)
133
+ valid_assets_links_from(document).each do |link|
134
+ validate_response_from(current_url, link)
135
+ end
136
+ end
137
+ end
138
+
139
+ #Example: And I should see that all links on the page are valid
140
+ Then /^I should see that all links on the page are valid$/ do
141
+ document = parse_dom_tree(current_url)
142
+ links_on(document).each do |link|
143
+ validate_response_from(current_url, link)
144
+ end
145
+ end
146
+
147
+
148
+ #************************ BUTTONS AND LINKS **************************************
149
+
150
+ #************************ PAGINATION **************************************
151
+
152
+ #Example: Then I should be on page 2
153
+ Then /^I should be on page (\d+)$/ do |page_number|
154
+ pagination_links_for(page_number).collect(&:disabled?).uniq.should == [true]
155
+ end
156
+
157
+ #************************ PAGINATION **************************************
158
+
159
+
160
+
161
+ #************************ LIST/ ERROR MESSAGES ***********************************
162
+
163
+ #TODO: Add a test
164
+ #Example: Then I should see the following errors: Accepts Gherkin Table
165
+ #Example: Not yet implemented
166
+ Then /^I should see the following(?: errors| list):$/ do |table|
167
+ column_header, *list = table.raw
168
+ list.flatten.each do |message|
169
+ patiently { page.should have_content(message) }
170
+ end
171
+ end
172
+
173
+
174
+ #************************ END LIST/ ERROR MESSAGES *******************************
175
+
176
+
177
+ #************************ TAGS ***************************************************
178
+
179
+ #Example: Then I should see a "td" tag around "bla"
180
+ Then /^I should see an? "([^"]*)" tag around the text "([^"]*)"$/ do |tag_name, text|
181
+ page.should have_xpath("//#{tag_name}[text()=\"#{text}\"]")
182
+ end
183
+
184
+ #Example: Then I should see a "div" with "id" of "ui-datepicker-div"
185
+ Then /^I should see an? "([^"]*)" with "([^"]*)" of "([^"]*)"$/ do |tag_name, attribute_name, attribute_value|
186
+ page.should have_xpath("//#{tag_name}[@#{attribute_name}=\"#{attribute_value}\"]")
187
+ end
188
+
189
+
190
+ #************************ END TAGS ***********************************************
191
+
192
+
193
+ #************************ IMAGES *************************************************
194
+
195
+ #TODO: Add Examples
196
+ #Example: Then I should see the image "Image1.jpg"
197
+ Then /^I should see the image "([^"]*)"$/ do |image_name|
198
+ page.should have_xpath("//img[contains(@src, \"#{image_name}\")]")
199
+ end
200
+
201
+ #Example: Then I should see all of the images: <accepts a list of image names(src)>
202
+ Then /^I should see all of the images:?$/ do |table|
203
+ table.raw.each do |text|
204
+ step "I should see the image \"#{text[0]}\""
205
+ end
206
+ end
207
+
208
+ #Example: Then I should see text "some alt text" as alt text for ImageSelector
209
+ Then /^(?:|I )should see text "(.*)" as alt text for (.*)$/ do |alt_text, locator|
210
+ selector, selector_type = selector_for(locator)
211
+ if selector_type == 'xpath'
212
+ patiently { page.should have_xpath("#{selector}[@alt='#{alt_text}']") }
213
+ elsif selector_type == 'css'
214
+ patiently { page.should have_css("#{selector}[alt='#{alt_text}']") }
215
+ else
216
+ patiently { page.should have_xpath("//img[contains(@src, '#{unquoted(selector)}')][@alt='#{alt_text}']") }
217
+ end
218
+ end
219
+
220
+
221
+ #************************ END IMAGES *********************************************
222
+
223
+
224
+ #************************ AUDIO **************************************************
225
+
226
+ #TODO: Add Examples
227
+ #Example: Then I should see the HTML5 audio source "Audio.mp3"
228
+ Then /^I should see the HTML5 audio source "([^"]*)"$/ do |audio_name|
229
+ page.should have_xpath("//audio[contains(@src, \"#{audio_name}\")] | //audio/source[contains(@src, \"#{audio_name}\")]")
230
+ end
231
+ #Example: Then I should see the HTML5 audio sources: <Accepts a list of audio file names>
232
+ Then /^I should see all of the HTML5 audio sources:?$/ do |table|
233
+ table.raw.each do |text|
234
+ step "I should see the HTML5 audio source \"#{text[0]}\""
235
+ end
236
+ end
237
+
238
+
239
+ #************************ END AUDIO **********************************************
240
+
241
+
242
+ #************************ VIDEO **************************************************
243
+
244
+ #TODO: Add Examples
245
+ #Example: Then I should see the HTML5 video source "video1.mp4"
246
+ Then /^I should see the HTML5 video source "([^"]*)"$/ do |video_name|
247
+ page.should have_xpath("//video[contains(@src, \"#{video_name}\")] | //video/source[contains(@src, \"#{video_name}\")]")
248
+ end
249
+
250
+ #Example: Then I should see the HTML5 video sources: <accepts a table of video sources>
251
+ Then /^I should see all of the HTML5 video sources:$/ do |table|
252
+ table.raw.each do |text|
253
+ step "I should see the HTML5 video source \"#{text[0]}\""
254
+ end
255
+ end
256
+
257
+
258
+ #************************ VIDEO **************************************************
259
+
260
+
261
+ #************************ OTHER ELEMENTS *****************************************
262
+
263
+
264
+ #TODO: Hate the language here, need to fix this
265
+ #Example: Then I should see 2 elements kind of table's header
266
+ Then /^I should see (\d+) elements? kind of (.+)$/ do |count, locator|
267
+ selector, xpath = selector_for(locator)
268
+ patiently do
269
+ actual_count = all(selector).count
270
+ count = count.to_i
271
+ actual_count.should eq(count)
272
+ end
273
+ end
274
+
275
+ #Example: And I should not see elements kind of paragraphs
276
+ Then /^I should not see elements? kind of (.+)$/ do |locator|
277
+ patiently { page.should_not have_css(selector_for(locator).first) }
278
+ end
279
+
280
+
281
+ #************************ END OTHER ELEMENTS *************************************
282
+
283
+
284
+
285
+ #Example: Not Implemented yet
286
+ Then /^I should see "(.*?)" as "(.*?)" value$/ do |arg1, arg2|
287
+ pending # express the regexp above with the code you wish you had
288
+ end
289
+
290
+
291
+ #*********************** SELECTOR SECTION ********************************
292
+
293
+
294
+ #Example: Then I should see the correct "MedicareGovHeader"
295
+ Then /^I should see the correct "(.*)"$/ do |section|
296
+ locators = selectors_from_section(section)
297
+ locators.each do |locator|
298
+ if is_css?(locator)
299
+ should have_css(selector_from(locator).first)
300
+ elsif is_xpath?(locator)
301
+ should have_xpath(selector_from(locator).first)
302
+ else
303
+ raise "Could not determine selector type for #{selector}"
304
+ end
305
+ end
306
+ end