SimpliTest 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +22 -0
  3. data/SimpliTest.gemspec +42 -0
  4. data/bin/SimpliTest +22 -0
  5. data/lib/SimpliTest.rb +2 -0
  6. data/lib/SimpliTest/cli/main.rb +305 -0
  7. data/lib/SimpliTest/config/configuration.rb +107 -0
  8. data/lib/SimpliTest/config/directory_paths.rb +36 -0
  9. data/lib/SimpliTest/config/environment.rb +67 -0
  10. data/lib/SimpliTest/config/local_environment.rb +20 -0
  11. data/lib/SimpliTest/config/profiles/chrome.rb +18 -0
  12. data/lib/SimpliTest/config/profiles/firefox.rb +14 -0
  13. data/lib/SimpliTest/config/profiles/internet_explorer.rb +12 -0
  14. data/lib/SimpliTest/config/profiles/phantom.rb +9 -0
  15. data/lib/SimpliTest/config/profiles/phantom_debug.rb +12 -0
  16. data/lib/SimpliTest/config/profiles/selenium.rb +13 -0
  17. data/lib/SimpliTest/config/screen_size.rb +25 -0
  18. data/lib/SimpliTest/config/steps.rb +8 -0
  19. data/lib/SimpliTest/helpers/data_validation.rb +60 -0
  20. data/lib/SimpliTest/helpers/file.rb +38 -0
  21. data/lib/SimpliTest/helpers/project_setup.rb +186 -0
  22. data/lib/SimpliTest/helpers/step_helpers/custom_chrome_helpers.rb +14 -0
  23. data/lib/SimpliTest/helpers/step_helpers/custom_date_helpers.rb +64 -0
  24. data/lib/SimpliTest/helpers/step_helpers/custom_form_helpers.rb +66 -0
  25. data/lib/SimpliTest/helpers/step_helpers/custom_phantomjs_helpers.rb +49 -0
  26. data/lib/SimpliTest/helpers/step_helpers/custom_selenium_helpers.rb +41 -0
  27. data/lib/SimpliTest/helpers/step_helpers/html_selectors_helpers.rb +154 -0
  28. data/lib/SimpliTest/helpers/step_helpers/navigation_helpers.rb +196 -0
  29. data/lib/SimpliTest/helpers/step_helpers/tolerance_for_sync_issues.rb +38 -0
  30. data/lib/SimpliTest/helpers/step_helpers/within_helpers.rb +6 -0
  31. data/lib/SimpliTest/helpers/windows_ui.rb +52 -0
  32. data/lib/SimpliTest/steps/debugging_steps.rb +19 -0
  33. data/lib/SimpliTest/steps/form_steps.rb +352 -0
  34. data/lib/SimpliTest/steps/form_verification_steps.rb +190 -0
  35. data/lib/SimpliTest/steps/navigation_steps.rb +47 -0
  36. data/lib/SimpliTest/steps/scoper.rb +42 -0
  37. data/lib/SimpliTest/steps/verification_steps.rb +306 -0
  38. data/lib/SimpliTest/tasks/document.rb +169 -0
  39. data/lib/SimpliTest/tasks/examples.rb +18 -0
  40. data/lib/SimpliTest/tasks/internal_release.rb +39 -0
  41. data/lib/SimpliTest/tasks/testinstall.rb +5 -0
  42. data/lib/SimpliTest/templates/NewSimpliTestProject/Readme.txt +5 -0
  43. data/lib/SimpliTest/templates/NewSimpliTestProject/cucumber.yml +26 -0
  44. data/lib/SimpliTest/templates/NewSimpliTestProject/documentation/step_definitions.html +87 -0
  45. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/RegressionTests/HelloWorld.feature +4 -0
  46. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/SmokeTest/HelloWorld.feature +4 -0
  47. data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/accessibilityTests/HelloWorld.feature +4 -0
  48. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/environments.yml +11 -0
  49. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/pages.yml +26 -0
  50. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/selectors.yml +44 -0
  51. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/settings.yml +26 -0
  52. data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/env.rb +33 -0
  53. data/lib/SimpliTest/templates/NewSimpliTestProject/license.txt +30 -0
  54. data/lib/SimpliTest/templates/document/css/style.css +28 -0
  55. data/lib/SimpliTest/templates/document/index.html +60 -0
  56. data/lib/version.rb +3 -0
  57. metadata +395 -0
@@ -0,0 +1,190 @@
1
+
2
+ #************************ TEXT FIELDS ********************************************
3
+
4
+ #Example: Then the "Name" field should contain "my name"
5
+ Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
6
+ with_scope(parent) do
7
+ field = get_element_from(field)
8
+ field_value = field.value
9
+ patiently { field_value.should =~ /#{value}/ }
10
+ end
11
+ end
12
+
13
+ #Example: And the "Name" field should not contain "not my name"
14
+ Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
15
+ with_scope(parent) do
16
+ field = get_element_from(field)
17
+ field_value = field.value
18
+ patiently { field_value.should_not =~ /#{value}/ }
19
+ end
20
+ end
21
+
22
+
23
+ #************************ END TEXT FIELDS ****************************************
24
+
25
+
26
+ #************************ DROP DOWNS *********************************************
27
+
28
+
29
+ #Example: Then the select "Your favorite colors": Table
30
+ Then /^the select "([^"]*)" should have following options:$/ do |field, options|
31
+ options = options.transpose.raw
32
+ if options.size > 1
33
+ raise 'table should have only one column in this step!'
34
+ else
35
+ options = options.first
36
+ end
37
+
38
+ actual_options = get_element_from(field).all('option').map { |option| option.text }
39
+ patiently { options.should eq(actual_options) }
40
+ end
41
+
42
+ #Example: And the following values should be selected in "Your favorite colors": Table
43
+ Then /^the following values should be selected in "([^"]*)":$/ do |select_box, values|
44
+ values = values.transpose.raw
45
+ if values.size > 1
46
+ raise 'table should have only one column in this step!'
47
+ else
48
+ values = values.first
49
+ end
50
+
51
+ select_box= get_element_from(select_box)
52
+ unless select_box['multiple']
53
+ raise "this is not multiple select box!"
54
+ else
55
+ values.each do |value|
56
+ patiently { select_box.value.should include(value) }
57
+ end
58
+ end
59
+ end
60
+
61
+ #Example: And the following values should not be selected in "Your favorite colors":
62
+ Then /^the following values should not be selected in "([^"]*)":$/ do |select_box, values|
63
+ values = values.transpose.raw
64
+ if values.size > 1
65
+ raise 'table should have only one column in this step!'
66
+ else
67
+ values = values.first
68
+ end
69
+
70
+ select_box= get_element_from(select_box)
71
+ unless select_box['multiple']
72
+ raise "this is not multiple select box!"
73
+ else
74
+ values.each do |value|
75
+ patiently { select_box.value.should_not include(value) }
76
+ end
77
+ end
78
+ end
79
+
80
+
81
+ #************************ END DROP DOWNS******************************************
82
+
83
+
84
+ #************************ CHECKBOXES *********************************************
85
+
86
+ #Example: And the "Accept user agrement" checkbox should be checked
87
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
88
+ with_scope(parent) do
89
+ field_checked = get_element_from(label)['checked']
90
+ patiently { field_checked.should be_truthy }
91
+ end
92
+ end
93
+
94
+ #Example: And the "Do not touch me" checkbox should not be checked
95
+ Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
96
+ with_scope(parent) do
97
+ field_checked = get_element_from(label)['checked']
98
+ patiently { field_checked.should be_falsey }
99
+ end
100
+ end
101
+
102
+ #Example: And the "Sex" selectbox should contain: Table
103
+ Then /^the "(.*?)" selectbox should contain:$/ do |locator, options|
104
+ patiently do
105
+ select_options_for(locator).should == options.raw.join(' ')
106
+ end
107
+ end
108
+
109
+
110
+ #************************ END CHECKBOXES *****************************************
111
+
112
+
113
+ #************************ RADIO BUTTONS*******************************************
114
+
115
+
116
+ #Example: And the "radio 1" radio should be selected
117
+ Then /^the "(.*?)" radio should be selected$/ do |locator|
118
+ patiently do
119
+ element = get_element_from(locator)
120
+ element.should be_checked
121
+ end
122
+ end
123
+ #Example: And the "radio 2" radio should not be selected
124
+ Then /^the "(.*?)" radio should not be selected$/ do |locator|
125
+ patiently do
126
+ element = get_element_from(locator)
127
+ element.should_not be_checked
128
+ end
129
+ end
130
+
131
+
132
+ #************************ END RADIO BUTTONS***************************************
133
+
134
+
135
+ #************************ DATE FIELD *********************************************
136
+
137
+
138
+ #Example: Then "12/31/2013" should be the default date for "datepicker"
139
+ Then /^"(.*?)" should be the default date for "(.*?)"$/ do |date_rule, field|
140
+ patiently do
141
+ date_field = get_element_from(field)
142
+ date_field.value.should == calculated_date_from(date_rule)
143
+ end
144
+ end
145
+
146
+
147
+ #************************ END DATE FIELD *****************************************
148
+
149
+
150
+
151
+ #****************Read from Excel
152
+
153
+ #****************User Name Field
154
+
155
+ #Example: Then I enter user name from excel in "Username"
156
+ Then /^I enter user name from excel in "(.*?)"$/ do |locator|
157
+ element = get_element_from(locator)
158
+
159
+ require 'spreadsheet'
160
+ Spreadsheet.client_encoding = 'UTF-8'
161
+ workbook = Spreadsheet.open 'C:\cmsmoketest\features\specifications\SmokeTest\book5.xls'
162
+ sheet1 = workbook.worksheet 0
163
+ sheet1.each 1 do |row|
164
+ #puts "#{row[0]} - #{row[1]} - #{row[2]}"
165
+ resolt = "#{row[0]}"
166
+ element.set resolt
167
+ end
168
+ end
169
+
170
+
171
+ #****************Password Field
172
+
173
+ #Example: Then I enter user name from excel in "Username"
174
+ Then(/^I enter password from excel in "([^"]*)" field$/) do |locator|
175
+ element = get_element_from(locator)
176
+ require 'spreadsheet'
177
+ Spreadsheet.client_encoding = 'UTF-8'
178
+ workbook = Spreadsheet.open 'C:\cmsmoketest\features\specifications\SmokeTest\book5.xls'
179
+ sheet1 = workbook.worksheet 0
180
+ sheet1.each 1 do |row|
181
+ resolt = "#{row[1]}"
182
+ element.set resolt
183
+ end
184
+
185
+ end
186
+
187
+ # Reads a plain text file
188
+ Then /[Rr]ead file "(.*?)"$/ do |filepath|
189
+ File.foreach(filepath) { |x| print 'Got ', x }
190
+ end
@@ -0,0 +1,47 @@
1
+ #Example: Given I am on the "home" page
2
+ Given /^(?:|I )am on the "(.*)" (?:page|Page)$/ do |page_name|
3
+ visit path_to(page_name)
4
+ maximize_window
5
+ end
6
+
7
+ #Example: When I go to the "other" page
8
+ When /^(?:|I )go to the "(.*)" page$/ do |page_name|
9
+ visit path_to(page_name)
10
+ end
11
+
12
+ #Example: When I follow "Privacy Policy"
13
+ When /^(?:|I )follow "([^"]*)"$/ do |link|
14
+ patiently { click_link(link) }
15
+ end
16
+
17
+ #Example: When I maximize the window
18
+ And /^(?:|I )maximize the window$/ do
19
+ maximize_window
20
+ end
21
+
22
+ #Example: And I switch to the last window
23
+ And /^(?:|I )switch to the (.*) window$/ do |first_or_last|
24
+ change_window(first_or_last)
25
+ end
26
+
27
+
28
+ #Example: And I switch to the frame
29
+ And /^(?:|I )[Ss]witch to the frame$/ do
30
+ page.driver.browser.switch_to.frame(1)
31
+ end
32
+
33
+ # Accepts modal popups if they exist or fails gracefully if not
34
+
35
+ #Example: Then I Accept the popup window
36
+ Then /^(?:|I )[Aa]ccept (?:|the )popup(?:| window)$/ do
37
+ page.driver.browser.switch_to.alert.accept rescue Selenium::WebDriver::Error::NoAlertPresentError
38
+ end
39
+
40
+ #Dismisses modal popups if they exist or fails gracefully if not
41
+
42
+ #Example: Then I Dismiss the popup window
43
+ Then /^(?:|I )[Dd]ismiss (?:|the )popup(?:| window)$/ do
44
+ page.driver.browser.switch_to.alert.dismiss rescue Selenium::WebDriver::Error::NoAlertPresentError
45
+ end
46
+
47
+ #-------------------------------------------------------
@@ -0,0 +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
+
@@ -0,0 +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