druid-s 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +1 -0
  4. data/.rvmrc +1 -0
  5. data/.travis.yml +27 -0
  6. data/ChangeLog +541 -0
  7. data/Gemfile +8 -0
  8. data/README.md +78 -0
  9. data/Rakefile +33 -0
  10. data/cucumber.yml +6 -0
  11. data/druid.gemspec +30 -0
  12. data/features/area.feature +33 -0
  13. data/features/async.feature +16 -0
  14. data/features/audio.feature +61 -0
  15. data/features/bold.feature +20 -0
  16. data/features/button.feature +81 -0
  17. data/features/canvas.feature +34 -0
  18. data/features/checkbox.feature +48 -0
  19. data/features/div.feature +45 -0
  20. data/features/element.feature +281 -0
  21. data/features/file_field.feature +38 -0
  22. data/features/form.feature +37 -0
  23. data/features/frames.feature +76 -0
  24. data/features/generic_elements.feature +29 -0
  25. data/features/heading.feature +160 -0
  26. data/features/hidden_field.feature +39 -0
  27. data/features/html/async.html +31 -0
  28. data/features/html/frame_1.html +18 -0
  29. data/features/html/frame_2.html +16 -0
  30. data/features/html/frame_3.html +14 -0
  31. data/features/html/frames.html +12 -0
  32. data/features/html/hover.html +11 -0
  33. data/features/html/iframes.html +12 -0
  34. data/features/html/images/circle.png +0 -0
  35. data/features/html/images/img_pulpit.jpg +0 -0
  36. data/features/html/modal.html +17 -0
  37. data/features/html/modal_1.html +38 -0
  38. data/features/html/modal_2.html +27 -0
  39. data/features/html/multi_elements.html +145 -0
  40. data/features/html/nested_elements.html +75 -0
  41. data/features/html/nested_frame_1.html +1 -0
  42. data/features/html/nested_frame_2.html +11 -0
  43. data/features/html/nested_frame_3.html +14 -0
  44. data/features/html/nested_frames.html +10 -0
  45. data/features/html/planets.gif +0 -0
  46. data/features/html/static_elements.html +203 -0
  47. data/features/html/success.html +8 -0
  48. data/features/html/sun.gif +0 -0
  49. data/features/html/sun.html +7 -0
  50. data/features/image.feature +47 -0
  51. data/features/italic.feature +20 -0
  52. data/features/javascript.feature +28 -0
  53. data/features/label.feature +43 -0
  54. data/features/link.feature +56 -0
  55. data/features/list_item.feature +37 -0
  56. data/features/modal_dialog.feature +9 -0
  57. data/features/multi_elements.feature +498 -0
  58. data/features/nested_elements.feature +121 -0
  59. data/features/ordered_list.feature +46 -0
  60. data/features/page_level_actions.feature +116 -0
  61. data/features/paragraph.feature +33 -0
  62. data/features/populate_page_with.feature +25 -0
  63. data/features/radio_button.feature +51 -0
  64. data/features/radio_button_group.feature +28 -0
  65. data/features/sample-app/public/04-Death_Becomes_Fur.mp4 +0 -0
  66. data/features/sample-app/public/04-Death_Becomes_Fur.oga +0 -0
  67. data/features/sample-app/public/audio_video.html +19 -0
  68. data/features/sample-app/public/jquery-1.3.2.js +4376 -0
  69. data/features/sample-app/public/jquery.html +28 -0
  70. data/features/sample-app/public/movie.mp4 +0 -0
  71. data/features/sample-app/public/movie.ogg +0 -0
  72. data/features/sample-app/public/prototype-1.6.0.3.js +4320 -0
  73. data/features/sample-app/public/prototype.html +32 -0
  74. data/features/sample-app/sample_app.rb +35 -0
  75. data/features/section.feature +132 -0
  76. data/features/select_list.feature +84 -0
  77. data/features/span.feature +43 -0
  78. data/features/step_definations/area_steps.rb +23 -0
  79. data/features/step_definations/async_steps.rb +80 -0
  80. data/features/step_definations/audio_steps.rb +47 -0
  81. data/features/step_definations/bold_steps.rb +11 -0
  82. data/features/step_definations/button_steps.rb +52 -0
  83. data/features/step_definations/canvas_steps.rb +19 -0
  84. data/features/step_definations/checkbox_steps.rb +39 -0
  85. data/features/step_definations/div_steps.rb +28 -0
  86. data/features/step_definations/element_steps.rb +217 -0
  87. data/features/step_definations/file_field_steps.rb +31 -0
  88. data/features/step_definations/form_steps.rb +23 -0
  89. data/features/step_definations/frame_steps.rb +189 -0
  90. data/features/step_definations/generic_element_steps.rb +31 -0
  91. data/features/step_definations/heading_steps.rb +39 -0
  92. data/features/step_definations/hidden_field_steps.rb +27 -0
  93. data/features/step_definations/image_steps.rb +35 -0
  94. data/features/step_definations/italic_steps.rb +11 -0
  95. data/features/step_definations/javasript_steps.rb +52 -0
  96. data/features/step_definations/label_steps.rb +19 -0
  97. data/features/step_definations/link_steps.rb +42 -0
  98. data/features/step_definations/list_item_steps.rb +24 -0
  99. data/features/step_definations/modal_dialog_steps.rb +38 -0
  100. data/features/step_definations/multi_elements_steps.rb +557 -0
  101. data/features/step_definations/nested_elements_steps.rb +219 -0
  102. data/features/step_definations/ordered_list_steps.rb +49 -0
  103. data/features/step_definations/page_level_actions_steps.rb +172 -0
  104. data/features/step_definations/page_traversal_steps.rb +4 -0
  105. data/features/step_definations/paragraph_steps.rb +19 -0
  106. data/features/step_definations/populate_page_with_steps.rb +3 -0
  107. data/features/step_definations/radio_button_group_steps.rb +32 -0
  108. data/features/step_definations/radio_button_steps.rb +31 -0
  109. data/features/step_definations/section_steps.rb +271 -0
  110. data/features/step_definations/select_list_steps.rb +91 -0
  111. data/features/step_definations/span_steps.rb +23 -0
  112. data/features/step_definations/table_cell_steps.rb +27 -0
  113. data/features/step_definations/table_row_steps.rb +23 -0
  114. data/features/step_definations/table_steps.rb +109 -0
  115. data/features/step_definations/text_area_steps.rb +39 -0
  116. data/features/step_definations/text_field_steps.rb +39 -0
  117. data/features/step_definations/unordered_list_steps.rb +27 -0
  118. data/features/step_definations/video_steps.rb +27 -0
  119. data/features/support/ajax_test_environment.rb +26 -0
  120. data/features/support/audio_video_page.rb +23 -0
  121. data/features/support/env.rb +5 -0
  122. data/features/support/hooks.rb +3 -0
  123. data/features/support/page.rb +372 -0
  124. data/features/support/persistent_browser.rb +58 -0
  125. data/features/support/targets/firefox14_osx.rb +5 -0
  126. data/features/support/targets/firefox14_windows7.rb +5 -0
  127. data/features/support/url_helper.rb +50 -0
  128. data/features/table.feature +127 -0
  129. data/features/table_cell.feature +42 -0
  130. data/features/table_row.feature +30 -0
  131. data/features/text_area.feature +44 -0
  132. data/features/text_field.feature +53 -0
  133. data/features/unordered_list.feature +46 -0
  134. data/features/video.feature +66 -0
  135. data/lib/druid/accessors.rb +1082 -0
  136. data/lib/druid/assist.rb +653 -0
  137. data/lib/druid/element_locators.rb +21 -0
  138. data/lib/druid/elements/area.rb +9 -0
  139. data/lib/druid/elements/audio.rb +9 -0
  140. data/lib/druid/elements/bold.rb +8 -0
  141. data/lib/druid/elements/button.rb +12 -0
  142. data/lib/druid/elements/canvas.rb +9 -0
  143. data/lib/druid/elements/check_box.rb +9 -0
  144. data/lib/druid/elements/div.rb +9 -0
  145. data/lib/druid/elements/element.rb +187 -0
  146. data/lib/druid/elements/file_field.rb +9 -0
  147. data/lib/druid/elements/form.rb +9 -0
  148. data/lib/druid/elements/heading.rb +14 -0
  149. data/lib/druid/elements/hidden_field.rb +9 -0
  150. data/lib/druid/elements/image.rb +9 -0
  151. data/lib/druid/elements/italic.rb +9 -0
  152. data/lib/druid/elements/label.rb +8 -0
  153. data/lib/druid/elements/link.rb +9 -0
  154. data/lib/druid/elements/list_item.rb +9 -0
  155. data/lib/druid/elements/media.rb +11 -0
  156. data/lib/druid/elements/option.rb +9 -0
  157. data/lib/druid/elements/ordered_list.rb +29 -0
  158. data/lib/druid/elements/paragraph.rb +9 -0
  159. data/lib/druid/elements/radio_button.rb +9 -0
  160. data/lib/druid/elements/select_list.rb +30 -0
  161. data/lib/druid/elements/span.rb +9 -0
  162. data/lib/druid/elements/table.rb +92 -0
  163. data/lib/druid/elements/table_cell.rb +11 -0
  164. data/lib/druid/elements/table_row.rb +50 -0
  165. data/lib/druid/elements/text_area.rb +10 -0
  166. data/lib/druid/elements/text_field.rb +11 -0
  167. data/lib/druid/elements/unordered_list.rb +32 -0
  168. data/lib/druid/elements/video.rb +8 -0
  169. data/lib/druid/elements.rb +55 -0
  170. data/lib/druid/javascript/angularjs.rb +12 -0
  171. data/lib/druid/javascript/jquery.rb +12 -0
  172. data/lib/druid/javascript/prototype.rb +12 -0
  173. data/lib/druid/javascript/yui.rb +19 -0
  174. data/lib/druid/javascript_framework_facade.rb +76 -0
  175. data/lib/druid/locator_generator.rb +181 -0
  176. data/lib/druid/nested_elements.rb +56 -0
  177. data/lib/druid/page_factory.rb +115 -0
  178. data/lib/druid/page_populator.rb +104 -0
  179. data/lib/druid/section_collection.rb +17 -0
  180. data/lib/druid/version.rb +3 -0
  181. data/lib/druid.rb +452 -0
  182. data/spec/druid/accessors_spec.rb +1209 -0
  183. data/spec/druid/druid_spec.rb +295 -0
  184. data/spec/druid/element_locators_spec.rb +750 -0
  185. data/spec/druid/elements/bold_spec.rb +12 -0
  186. data/spec/druid/elements/button_spec.rb +23 -0
  187. data/spec/druid/elements/check_box_spec.rb +14 -0
  188. data/spec/druid/elements/div_spec.rb +10 -0
  189. data/spec/druid/elements/element_spec.rb +250 -0
  190. data/spec/druid/elements/file_field_spec.rb +13 -0
  191. data/spec/druid/elements/form_spec.rb +18 -0
  192. data/spec/druid/elements/heading_spec.rb +30 -0
  193. data/spec/druid/elements/hidden_field_spec.rb +10 -0
  194. data/spec/druid/elements/image_spec.rb +23 -0
  195. data/spec/druid/elements/itatic_spec.rb +11 -0
  196. data/spec/druid/elements/label_spec.rb +10 -0
  197. data/spec/druid/elements/link_spec.rb +10 -0
  198. data/spec/druid/elements/list_item_spec.rb +10 -0
  199. data/spec/druid/elements/media_spec.rb +12 -0
  200. data/spec/druid/elements/option_spec.rb +21 -0
  201. data/spec/druid/elements/ordered_list_spec.rb +38 -0
  202. data/spec/druid/elements/page_factory_spec.rb +40 -0
  203. data/spec/druid/elements/paragraph_spec.rb +12 -0
  204. data/spec/druid/elements/radio_button_spec.rb +14 -0
  205. data/spec/druid/elements/select_list_spec.rb +51 -0
  206. data/spec/druid/elements/span_spec.rb +10 -0
  207. data/spec/druid/elements/table_cell_spec.rb +14 -0
  208. data/spec/druid/elements/table_row_spec.rb +34 -0
  209. data/spec/druid/elements/table_spec.rb +47 -0
  210. data/spec/druid/elements/text_area_spec.rb +13 -0
  211. data/spec/druid/elements/text_field_spec.rb +22 -0
  212. data/spec/druid/elements/unordered_list_spec.rb +39 -0
  213. data/spec/druid/javascript_framework_facade_spec.rb +59 -0
  214. data/spec/druid/nested_element_spec.rb +128 -0
  215. data/spec/druid/page_factory_spec.rb +235 -0
  216. data/spec/druid/page_populator_spec.rb +173 -0
  217. data/spec/druid/page_section_spec.rb +70 -0
  218. data/spec/spec_helper.rb +9 -0
  219. metadata +517 -0
@@ -0,0 +1,217 @@
1
+ Then(/^I should know its' text is "(.*?)"$/) do |text|
2
+ expect(@element.text).to eql text
3
+ end
4
+
5
+ Then(/^I should know it is equal to itself$/) do
6
+ expect(@element==@element).to be true
7
+ end
8
+
9
+ Then(/^I should know its' tag name is "(.*?)"$/) do |tagname|
10
+ expect(@element.tag_name).to eql tagname
11
+ end
12
+
13
+ Then(/^I should know the attribute "(.*?)" is false$/) do |attr_name|
14
+ @attr = @element.attribute(attr_name)
15
+ # expect(@attr.is_a? NilClass).to be true
16
+ expect(@attr).to be_nil
17
+ end
18
+
19
+ Then(/^I should be able to click it$/) do
20
+ @element.click
21
+ end
22
+
23
+ Then(/^I should know its' value is "(.*?)"$/) do |value|
24
+ expect(@element.value).to eql value
25
+ end
26
+
27
+ Then(/^I should know its' text includes "(.*?)"$/) do |text|
28
+ expect(@element.text).to include text
29
+ end
30
+
31
+ Then(/^I should know it is not visible$/) do
32
+ expect(@element.present?).to be false
33
+ end
34
+
35
+ When(/^I clear the text field$/) do
36
+ @page.text_field_id_element.clear
37
+ end
38
+
39
+ When(/^I retrieve a heading element$/) do
40
+ @element = @page.h1_id_element
41
+ end
42
+
43
+ When(/^I click an enabled button$/) do
44
+ @element = @page.button_id_element
45
+ end
46
+
47
+ Then(/^it should know it is enabled$/) do
48
+ expect(@element.enabled?).to be true
49
+ end
50
+
51
+ When(/^I check a disabled button$/) do
52
+ @element = @page.disabled_button_element
53
+ end
54
+
55
+ Then(/^it should know it is not enabled$/) do
56
+ expect(@element.enabled?).not_to be true
57
+ end
58
+
59
+ When(/^I set the focus to the test text_field using the onfocus event$/) do
60
+ @page.text_field_element(:id => 'onfocus_text_field').fire_event('onfocus')
61
+ end
62
+
63
+ Then(/^I should see the onfocus text "([^"]*)"$/) do |text|
64
+ expect(@page.div_element(:id => 'onfocus_test').text).to eql text
65
+ end
66
+
67
+ When(/^I set the focus on the test text_field$/) do
68
+ @page.text_field_element(:id => 'text_field_id').click
69
+ # Focuses element. Note that Firefox queues focus events until the window actually has focus.
70
+ @page.text_field_element(:id => 'onfocus_text_field').focus
71
+ end
72
+
73
+ When(/^I find the child link element$/) do
74
+ @element = @page.child_element
75
+ end
76
+
77
+ When(/^ask for the parent element$/) do
78
+ @parent = @element.parent
79
+ end
80
+
81
+ Then(/^I should have a div parent$/) do
82
+ expect(@parent).to be_instance_of Druid::Elements::Div
83
+ end
84
+
85
+ Then(/^it should know that it is not disabled$/) do
86
+ expect(@element).not_to be_disabled
87
+ end
88
+
89
+ Then(/^it should know that it is disabled$/) do
90
+ expect(@element).to be_disabled
91
+ end
92
+
93
+ When(/^I set the focus to the test text_field$/) do
94
+ @page.text_field_element(:id => 'onfocus_text_field').focus
95
+ end
96
+
97
+ Then(/^I should know that the text_field has the focus$/) do
98
+ element = @page.element_with_focus
99
+ expect(element).not_to be nil
100
+ expect(element.class).to be Druid::Elements::TextField
101
+ end
102
+
103
+ When(/^I retrieve the label element$/) do
104
+ @element = @page.label_id_element
105
+ end
106
+
107
+ Then(/^I should be able to flash it$/) do
108
+ @element.flash
109
+ end
110
+
111
+ class HoverPage
112
+ include Druid
113
+
114
+ link(:hello)
115
+ end
116
+
117
+ Given(/^I am on the hover page$/) do
118
+ @page = HoverPage.new(@driver)
119
+ @page.navigate_to UrlHelper.hover
120
+ end
121
+
122
+ When(/^I hover over the hello link$/) do
123
+ @page.hello_element.hover
124
+ end
125
+
126
+ Then(/^the font size should be "([^"]*)"$/) do |font_size|
127
+ expect(@page.hello_element.style('font-size')).to eql font_size
128
+ end
129
+
130
+ Then(/^I should know its id is "([^"]*)"$/) do |id|
131
+ expect(@element.id).to eql id
132
+ end
133
+
134
+ Then(/^I should know the html is "(.*)"$/) do |html|
135
+ expect(@element.html).to eql html
136
+ end
137
+
138
+ Then(/^the heading element should be visible$/) do
139
+ expect(@element.present?).to be true
140
+ end
141
+
142
+ When(/^I retrieve a div using data\-entity$/) do
143
+ @element = @page.div_data_entity_element
144
+ end
145
+
146
+ Then(/^I should know the text is "([^"]*)"$/) do |text|
147
+ expect(@element.text).to eql text
148
+ end
149
+
150
+ When(/^I retrieve the figure uisng the declaration$/) do
151
+ @element = @page.figure_id_element
152
+ end
153
+
154
+ Then(/^I should see the figure contains an image$/) do
155
+ expect(@element.image_element).not_to be nil
156
+ end
157
+
158
+ When(/^I retrieve the figure using the element$/) do
159
+ @element = @page.figure_element(:id => 'figure_id')
160
+ end
161
+
162
+ Then(/^I should know the attribute "([^"]*)" includes "([^"]*)"$/) do |attribute, included|
163
+ @attr = @element.attribute(attribute)
164
+ expect(@attr).to include included
165
+ end
166
+
167
+ Then(/^I should know the paragraph class is "([^"]*)"$/) do |class_name|
168
+ expect(@page.p_id_element.class_name).to eql class_name
169
+ end
170
+
171
+ Then(/^I should be able to select "([^"]*)" from the paragraph$/) do |text|
172
+ @page.p_id_element.select_text text
173
+ end
174
+
175
+ Then(/^I should be able to know its location$/) do
176
+ expect(@element.location.y).to be > 0
177
+ expect(@element.location.x).to be > 0
178
+ end
179
+
180
+ Then(/^I should be able to know its size$/) do
181
+ expect(@element.size.width).to be > 0
182
+ expect(@element.size.height).to be > 0
183
+ end
184
+
185
+ Then(/^the element width is not 0$/) do
186
+ expect(@element.width.is_a? Integer).to be true
187
+ expect(@element.width).to be > 0
188
+ end
189
+
190
+ Then(/^the element height is not 0$/) do
191
+ expect(@element.height.is_a? Integer).to be true
192
+ expect(@element.height).to be > 0
193
+ end
194
+
195
+ Then(/^the element centre should be greater than element y position$/) do
196
+ expect(@element.centre['y']).to be > @element.location.y
197
+ end
198
+
199
+ Then(/^the element centre should be greater than element x position$/) do
200
+ expect(@element.centre['x']).to be > @element.location.x
201
+ end
202
+
203
+ When(/^I retrieve the focus state of the text_field$/) do
204
+ @focused_state = @page.text_field_onfocus_element.focused?
205
+ end
206
+
207
+ Then(/^I should know that the text_field is focused$/) do
208
+ expect(@focused_state).to be true
209
+ end
210
+
211
+ Given(/^I set the focus off the test text_field$/) do
212
+ @page.text_field_unfocus_element.focus
213
+ end
214
+
215
+ Then(/^I should know that the text_field is not focused$/) do
216
+ expect(@focused_state).to be false
217
+ end
@@ -0,0 +1,31 @@
1
+ When(/^I set the file field to the step definition file$/) do
2
+ @page.file_field_id = __FILE__
3
+ end
4
+
5
+ Then(/^This filefield element should exist$/) do
6
+ expect(@page.file_field_id_element.exist?).to be true
7
+ end
8
+
9
+ When(/^I search for the file field by "([^"]*)"$/) do |how|
10
+ @how = how
11
+ end
12
+
13
+ Then(/^I should be able to set the file field$/) do
14
+ @page.send "file_field_#{@how}=", __FILE__
15
+ end
16
+
17
+ When(/^I search for the file field by "([^"]*)" and "([^"]*)"$/) do |param1, param2|
18
+ @how = "#{param1}_#{param2}"
19
+ end
20
+
21
+ When(/^I locate a file field while the script is executing$/) do
22
+ @element = @page.file_field_element(:id => 'file_field_id')
23
+ end
24
+
25
+ Then(/^The file field should exist$/) do
26
+ expect(@element.exist?).to be true
27
+ end
28
+
29
+ Then(/^I should see that the file field element exists$/) do
30
+ expect(@page.file_field_id?).to be true
31
+ end
@@ -0,0 +1,23 @@
1
+ When(/^I locate the form by "(.*?)"$/) do |how|
2
+ @element = @page.send "form_#{how}_element"
3
+ end
4
+
5
+ Then(/^I should be able to submit the form$/) do
6
+ @element.submit
7
+ end
8
+
9
+ When(/^I locate the form using "(.*?)" and "(.*?)"$/) do |param1, param2|
10
+ @element = @page.send "form_#{param1}_#{param2}_element"
11
+ end
12
+
13
+ When(/^I locate the form$/) do
14
+ @element = @page.form_id_element
15
+ end
16
+
17
+ When(/^I locate a form while the script is executing$/) do
18
+ @element = @page.form_element(:id => 'form_id')
19
+ end
20
+
21
+ Then(/^I should see that the form exists$/) do
22
+ expect(@page.form_id?).to be true
23
+ end
@@ -0,0 +1,189 @@
1
+ class FramePage
2
+ include Druid
3
+
4
+ in_frame(:id => "frame_two_2") do |frame|
5
+ text_field(:text_field_2_id, :name => 'recieverElement', :frame => frame)
6
+ end
7
+
8
+ in_frame(:name => "frame2") do |frame|
9
+ text_field(:text_field_2_name, :name => 'recieverElement', :frame => frame)
10
+ end
11
+
12
+ in_frame(:index => 1) do |frame|
13
+ text_field(:text_field_2_index, :name => 'recieverElement', :frame => frame)
14
+ end
15
+
16
+ in_frame(:id => "frame_one_1") do |frame|
17
+ text_field(:text_field_1_id, :name => 'senderElement', :frame => frame)
18
+ end
19
+
20
+ in_frame(:name => "frame1") do |frame|
21
+ text_field(:text_field_1_name, :name => 'senderElement', :frame => frame)
22
+ end
23
+
24
+ in_frame(:index => 0) do |frame|
25
+ text_field(:text_field_1_index, :name => 'senderElement', :frame => frame)
26
+ end
27
+
28
+ in_frame(:id => /frame_two_\d+/) do |frame|
29
+ text_field(:text_field_2_regex, :name => 'recieverElement', :frame => frame)
30
+ end
31
+
32
+ end
33
+
34
+ class IFramePage
35
+ include Druid
36
+
37
+ in_iframe(:id => 'frame_two_2') do |frame|
38
+ text_field(:text_field_2_id, :name => 'recieverElement', :frame => frame)
39
+ end
40
+ in_iframe(:id => 'frame_one_1') do |frame|
41
+ text_field(:text_field_1_id, :name => 'senderElement', :frame => frame)
42
+ end
43
+ in_iframe(:name => 'frame2') do |frame|
44
+ text_field(:text_field_2_name, :name => 'recieverElement', :frame => frame)
45
+ end
46
+ in_iframe(:name => 'frame1') do |frame|
47
+ text_field(:text_field_1_name, :name => 'senderElement', :frame => frame)
48
+ end
49
+ in_iframe(:index => 1) do |frame|
50
+ text_field(:text_field_2_index, :name => 'recieverElement', :frame => frame)
51
+ end
52
+ in_iframe(:index => 0) do |frame|
53
+ text_field(:text_field_1_index, :name => 'senderElement', :frame => frame)
54
+ end
55
+ in_iframe(:class => 'iframe', :name => 'frame2') do |frame|
56
+ text_field(:text_field_2_multiple_identifiers, :name => 'recieverElement', :frame => frame)
57
+ end
58
+ end
59
+
60
+ class FrameSectionPageSection
61
+ include Druid
62
+
63
+ paragraph :p_in_section
64
+
65
+ in_iframe(id: 'three') do |frame|
66
+ link :success, id: 'four', frame: frame
67
+ end
68
+
69
+ end
70
+
71
+ class FrameSectionPage
72
+ include Druid
73
+
74
+ in_frame(id: 'two') do |frame|
75
+ page_section :frame_section, FrameSectionPageSection, tag_name: 'body', frame: frame
76
+ paragraph :p_on_page, frame: frame
77
+ end
78
+
79
+ end
80
+
81
+ Given(/^I am on the frame section page$/) do
82
+ @page = FrameSectionPage.new(@driver)
83
+ @page.navigate_to(UrlHelper.nested_frame_elements)
84
+ end
85
+
86
+ Then(/^I should be able to access an element in the frame in the section repeatedly$/) do
87
+ expect(@page.p_on_page_element).to be_present
88
+ expect(@page.frame_section.p_in_section_element).to be_present
89
+ expect(@page.frame_section.success_element).to be_present
90
+ expect(@page.frame_section.success_element.text).to eq "this link should open the page success page"
91
+ @page.frame_section.success
92
+ expect(@page.text.strip).to eq 'Success'
93
+ end
94
+
95
+ Given(/^I am on the frame elements page$/) do
96
+ @page = FramePage.new(@driver)
97
+ @page.navigate_to(UrlHelper.frame_elements)
98
+ end
99
+
100
+ When(/^I type "(.*?)" into the text field for frame 2 using "(.*?)"$/) do |text, arg_type|
101
+ @page.send "text_field_2_#{arg_type.gsub(' ','_')}=".to_sym, text
102
+ end
103
+
104
+ Then(/^I should verify "(.*?)" is in the text field for frame 2 using "(.*?)"$/) do |text, arg_type|
105
+ result = @page.send "text_field_2_#{arg_type.gsub(' ','_')}".to_sym
106
+ expect(result).to eql text
107
+ end
108
+
109
+ When(/^I type "(.*?)" into the text field from frame 1 using "(.*?)"$/) do |text, arg_type|
110
+ @page.send "text_field_1_#{arg_type}=".to_sym, text
111
+ end
112
+
113
+ Then(/^I should verify "(.*?)" is in the text field for frame 1 using "(.*?)"$/) do |text, arg_type|
114
+ result = @page.send "text_field_1_#{arg_type}".to_sym
115
+ expect(result).to eql text
116
+ end
117
+
118
+ Given(/^I am on the iframe elements page$/) do
119
+ @page = IFramePage.new(@driver)
120
+ @page.navigate_to(UrlHelper.iframe_elements)
121
+ end
122
+
123
+ class NestedFramePage
124
+ include Druid
125
+
126
+ in_frame(:id => 'two') do |frame|
127
+ in_iframe({:id => 'three'}, frame) do |nested_frame|
128
+ link(:nested_link, :id => 'four', :frame => nested_frame)
129
+ end
130
+ end
131
+ end
132
+
133
+ Given(/^I am on the nested frame elements page$/) do
134
+ @page = NestedFramePage.new(@driver)
135
+ @page.navigate_to(UrlHelper.nested_frame_elements)
136
+ end
137
+
138
+ Then(/^I should be able to click the link in the frame$/) do
139
+ @page.nested_link
140
+ expect(@page.text).to include 'Success'
141
+ end
142
+
143
+ When(/^I type "([^"]*)" into the text field from frame 1 identified dynamically$/) do |value|
144
+ @page.in_frame(:id => 'frame_one_1') do |frame|
145
+ @page.text_field_element(:name => 'senderElement', :frame => frame).value = value
146
+ end
147
+ end
148
+
149
+ Then(/^I should verify "([^"]*)" in the text field for frame 1 identified dynamically$/) do |value|
150
+ @page.in_frame(:id => 'frame_one_1') do |frame|
151
+ expect(@page.text_field_element(:name => 'senderElement', :frame => frame).value).to eql value
152
+ end
153
+ end
154
+
155
+ When(/^I trigger an alert within a frame$/) do
156
+ @page.in_frame(:id => 'frame_three_3') do |frame|
157
+ @msg = @page.alert do
158
+ @page.button_element(:id => 'alert_button', :frame => frame).click
159
+ end
160
+ end
161
+ end
162
+
163
+ When(/^I trigger an confirm within a frame$/) do
164
+ @page.in_frame(:id => 'frame_three_3') do |frame|
165
+ @msg = @page.confirm(true) do
166
+ @page.button_element(:id => 'confirm_button', :frame => frame).click
167
+ end
168
+ end
169
+ end
170
+
171
+ When(/^I trigger an prompt within a frame$/) do
172
+ @page.in_frame(:id => 'frame_three_3') do |frame|
173
+ @msg = @page.prompt("Tim") do
174
+ @page.button_element(:id => 'prompt_button', :frame => frame).click
175
+ end
176
+ end
177
+ end
178
+
179
+ When(/^I type "([^"]*)" into the text field from iframe 1 identified dynamically$/) do |value|
180
+ @page.in_iframe(:id => 'frame_one_1') do |frame|
181
+ @page.text_field_element(:name => 'senderElement', :frame => frame).value = value
182
+ end
183
+ end
184
+
185
+ Then(/^I should verify "([^"]*)" in the text field for iframe 1 identified dynamically$/) do |value|
186
+ @page.in_iframe(:id => 'frame_one_1') do |frame|
187
+ expect(@page.text_field_element(:name => 'senderElement', :frame => frame).value).to eql value
188
+ end
189
+ end
@@ -0,0 +1,31 @@
1
+ When(/^I get the text from the article$/) do
2
+ @text = @page.article_id
3
+ end
4
+
5
+ When(/^I get the text from the header$/) do
6
+ @text = @page.header_id
7
+ end
8
+
9
+ When(/^I get the text from the footer$/) do
10
+ @text = @page.footer_id
11
+ end
12
+
13
+ When(/^I get the text from the summary$/) do
14
+ @text = @page.summary_id
15
+ end
16
+
17
+ When(/^I get the text from the details$/) do
18
+ @text = @page.details_id
19
+ end
20
+
21
+ When(/^I get the svg element$/) do
22
+ @svg= @page.svg_id_element
23
+ end
24
+
25
+ Then(/^the svg width should be "([^"]*)"$/) do |width|
26
+ expect(@svg.attribute('width')).to eql width
27
+ end
28
+
29
+ Then(/^the svg height should be "([^"]*)"$/) do |height|
30
+ expect(@svg.attribute('height')).to eql height
31
+ end
@@ -0,0 +1,39 @@
1
+ When(/^I get the text for the "([^"]*)" element$/) do |el|
2
+ @heading = @page.send "#{el}_id"
3
+ end
4
+
5
+ Then(/^I should see "([^"]*)"$/) do |text|
6
+ expect(@heading).to eql text
7
+ end
8
+
9
+ When(/^I search for the heading(\d+) by "([^"]*)"$/) do |head_type, type|
10
+ @heading = @page.send "h#{head_type}_#{type}"
11
+ end
12
+
13
+ When(/^I locate the h(\d+) using "([^"]*)" and "([^"]*)"$/) do |head_type, param1, param2|
14
+ @text = @page.send "h#{head_type}_#{param1}_#{param2}".to_sym
15
+ end
16
+
17
+ When(/^I locate a h1 while the script is executing$/) do
18
+ @text = @page.h1_element(:id => 'h1_id').text
19
+ end
20
+
21
+ When(/^I locate a h2 while the script is executing$/) do
22
+ @text = @page.h2_element(:id => 'h2_id').text
23
+ end
24
+
25
+ When(/^I locate a h3 while the script is executing$/) do
26
+ @text = @page.h3_element(:id => 'h3_id').text
27
+ end
28
+
29
+ When(/^I locate a h4 while the script is executing$/) do
30
+ @text = @page.h4_element(:id => 'h4_id').text
31
+ end
32
+
33
+ When(/^I locate a h5 while the script is executing$/) do
34
+ @text = @page.h5_element(:id => 'h5_id').text
35
+ end
36
+
37
+ When(/^I locate a h6 while the script is executing$/) do
38
+ @text = @page.h6_element(:id => 'h6_id').text
39
+ end
@@ -0,0 +1,27 @@
1
+ When(/^I retrieve the hidden field element$/) do
2
+ @element = @page.hidden_field_id_element
3
+ end
4
+
5
+ Then(/^I should see the hidden field contains "(.*?)"$/) do |text|
6
+ expect(@page.hidden_field_id).to eql text
7
+ end
8
+
9
+ When(/^I locate the hidden field by "(.*?)"$/) do |how|
10
+ @element = @page.send "hidden_field_#{how}_element".to_sym
11
+ end
12
+
13
+ Then(/^hidden field element should contains "(.*?)"$/) do |text|
14
+ expect(@element.value).to eql text
15
+ end
16
+
17
+ When(/^I search for the hidden field by "(.*?)" and "(.*?)"$/) do |param1, param2|
18
+ @element = @page.send "hidden_field_#{param1}_#{param2}_element".to_sym
19
+ end
20
+
21
+ When(/^I find a hidden field while the script is executing$/) do
22
+ @element = @page.hidden_field_element(:id => "hidden_field_id")
23
+ end
24
+
25
+ Then(/^I should see that the hidden field exists$/) do
26
+ expect(@page.hidden_field_id?).to be true
27
+ end
@@ -0,0 +1,35 @@
1
+ When(/^I get the image element$/) do
2
+ @element = @page.image_id_element
3
+ end
4
+
5
+ Then(/^the image should be "(.*?)" pixels wide$/) do |width|
6
+ expect(@element.width.to_s).to eql width
7
+ end
8
+
9
+ Then(/^the image should be "(.*?)" pixels tall$/) do |height|
10
+ expect(@element.height.to_s).to eql height
11
+ end
12
+
13
+ When(/^I get the image element by "(.*?)"$/) do |how|
14
+ @element = @page.send "image_#{how}_element".to_sym
15
+ end
16
+
17
+ When /^I get the image element bys "([^"]*)" and "([^"]*)"$/ do |param1, param2|
18
+ @element = @page.send "image_#{param1}_#{param2}_element"
19
+ end
20
+
21
+ When(/^I get the image element while the script is executing$/) do
22
+ @element = @page.image_element(:id => 'image_id')
23
+ end
24
+
25
+ Then(/^I should see that the image exists$/) do
26
+ expect(@page.image_id?).to be true
27
+ end
28
+
29
+ When(/^I get the image element load status$/) do
30
+ @status = @page.image_id_loaded?
31
+ end
32
+
33
+ Then(/^I should see that the image loaded$/) do
34
+ expect(@status).to be true
35
+ end
@@ -0,0 +1,11 @@
1
+ When(/^I get the italic text for the "([^"]*)" element$/) do |el|
2
+ @i = @page.send "#{el}_id"
3
+ end
4
+
5
+ Then(/^I should see "([^"]*)" in italic$/) do |text|
6
+ expect(@i).to eq text
7
+ end
8
+
9
+ When(/^I search italic text for the i by "([^"]*)"$/) do |how|
10
+ @i = @page.send "i_#{how}"
11
+ end
@@ -0,0 +1,52 @@
1
+ class JavascriptPage
2
+ include Druid
3
+
4
+ text_field(:expression, :id => 'calculator-expression')
5
+ text_field(:results, :id => 'calculator-result')
6
+ button(:compute, :value => 'Compute')
7
+ end
8
+
9
+ def build_url(page)
10
+ target = ENV['BROWSER']
11
+ return "http://localhost:4567/#{page}" if target.nil? or target.include? 'local'
12
+ "http://ec2-107-22-131-88.compute-1.amazonaws.com:4567/#{page}"
13
+ end
14
+
15
+ Given(/^I am on jQuery example page$/) do
16
+ Druid.javascript_framework = :jquery
17
+ @page = JavascriptPage.new(@driver)
18
+ @page.navigate_to build_url("jquery.html")
19
+ end
20
+
21
+ Given(/^I am on the Prototype example page$/) do
22
+ Druid.javascript_framework = :prototype
23
+ @page = JavascriptPage.new(@driver)
24
+ @page.navigate_to build_url("prototype.html")
25
+ end
26
+
27
+ When(/^I ask to compute "([^"]*)"$/) do |expression|
28
+ @page.expression = expression
29
+ @page.compute
30
+ end
31
+
32
+ Then(/^I should be able to wait for the answer "([^"]*)"$/) do |answer|
33
+ @page.wait_for_ajax
34
+ expect(@page.results).to eql answer
35
+ end
36
+
37
+ Given(/^I execute the javascript "([^"]*)"$/) do |script|
38
+ @answer = @page.execute_script script
39
+ end
40
+
41
+ Then(/^I should get the answer "([^"]*)"$/) do |answer|
42
+ expect(@answer).to eql answer.to_i
43
+ end
44
+
45
+ When(/^I execute the javascript "([^"]*)" with an argument of "([^"]*)"$/) do |script, arg|
46
+ @answer = @page.execute_script script, arg
47
+ end
48
+
49
+ When(/^I execute the javascript "([^"]*)" with a text field argument$/) do |script|
50
+ text_field = @page.text_field_element(:id => 'text_field_id')
51
+ @page.execute_script(script, text_field)
52
+ end
@@ -0,0 +1,19 @@
1
+ When(/^I get the text from the label$/) do
2
+ @text = @page.label_id
3
+ end
4
+
5
+ When(/^I search for the label by "([^"]*)"$/) do |how|
6
+ @text = @page.send "label_#{how}".to_sym
7
+ end
8
+
9
+ When(/^I search for the label by "([^"]*)" and "([^"]*)"$/) do |param1, param2|
10
+ @text = @page.send "label_#{param1}_#{param2}".to_sym
11
+ end
12
+
13
+ When(/^I get the text from a label while the script is executing$/) do
14
+ @text = @page.label_element(:id => 'label_id').text
15
+ end
16
+
17
+ Then(/^I should see that the label exists$/) do
18
+ expect(@page.label_id?).to be true
19
+ end