druid-s 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +27 -0
- data/ChangeLog +541 -0
- data/Gemfile +8 -0
- data/README.md +78 -0
- data/Rakefile +33 -0
- data/cucumber.yml +6 -0
- data/druid.gemspec +30 -0
- data/features/area.feature +33 -0
- data/features/async.feature +16 -0
- data/features/audio.feature +61 -0
- data/features/bold.feature +20 -0
- data/features/button.feature +81 -0
- data/features/canvas.feature +34 -0
- data/features/checkbox.feature +48 -0
- data/features/div.feature +45 -0
- data/features/element.feature +281 -0
- data/features/file_field.feature +38 -0
- data/features/form.feature +37 -0
- data/features/frames.feature +76 -0
- data/features/generic_elements.feature +29 -0
- data/features/heading.feature +160 -0
- data/features/hidden_field.feature +39 -0
- data/features/html/async.html +31 -0
- data/features/html/frame_1.html +18 -0
- data/features/html/frame_2.html +16 -0
- data/features/html/frame_3.html +14 -0
- data/features/html/frames.html +12 -0
- data/features/html/hover.html +11 -0
- data/features/html/iframes.html +12 -0
- data/features/html/images/circle.png +0 -0
- data/features/html/images/img_pulpit.jpg +0 -0
- data/features/html/modal.html +17 -0
- data/features/html/modal_1.html +38 -0
- data/features/html/modal_2.html +27 -0
- data/features/html/multi_elements.html +145 -0
- data/features/html/nested_elements.html +75 -0
- data/features/html/nested_frame_1.html +1 -0
- data/features/html/nested_frame_2.html +11 -0
- data/features/html/nested_frame_3.html +14 -0
- data/features/html/nested_frames.html +10 -0
- data/features/html/planets.gif +0 -0
- data/features/html/static_elements.html +203 -0
- data/features/html/success.html +8 -0
- data/features/html/sun.gif +0 -0
- data/features/html/sun.html +7 -0
- data/features/image.feature +47 -0
- data/features/italic.feature +20 -0
- data/features/javascript.feature +28 -0
- data/features/label.feature +43 -0
- data/features/link.feature +56 -0
- data/features/list_item.feature +37 -0
- data/features/modal_dialog.feature +9 -0
- data/features/multi_elements.feature +498 -0
- data/features/nested_elements.feature +121 -0
- data/features/ordered_list.feature +46 -0
- data/features/page_level_actions.feature +116 -0
- data/features/paragraph.feature +33 -0
- data/features/populate_page_with.feature +25 -0
- data/features/radio_button.feature +51 -0
- data/features/radio_button_group.feature +28 -0
- data/features/sample-app/public/04-Death_Becomes_Fur.mp4 +0 -0
- data/features/sample-app/public/04-Death_Becomes_Fur.oga +0 -0
- data/features/sample-app/public/audio_video.html +19 -0
- data/features/sample-app/public/jquery-1.3.2.js +4376 -0
- data/features/sample-app/public/jquery.html +28 -0
- data/features/sample-app/public/movie.mp4 +0 -0
- data/features/sample-app/public/movie.ogg +0 -0
- data/features/sample-app/public/prototype-1.6.0.3.js +4320 -0
- data/features/sample-app/public/prototype.html +32 -0
- data/features/sample-app/sample_app.rb +35 -0
- data/features/section.feature +132 -0
- data/features/select_list.feature +84 -0
- data/features/span.feature +43 -0
- data/features/step_definations/area_steps.rb +23 -0
- data/features/step_definations/async_steps.rb +80 -0
- data/features/step_definations/audio_steps.rb +47 -0
- data/features/step_definations/bold_steps.rb +11 -0
- data/features/step_definations/button_steps.rb +52 -0
- data/features/step_definations/canvas_steps.rb +19 -0
- data/features/step_definations/checkbox_steps.rb +39 -0
- data/features/step_definations/div_steps.rb +28 -0
- data/features/step_definations/element_steps.rb +217 -0
- data/features/step_definations/file_field_steps.rb +31 -0
- data/features/step_definations/form_steps.rb +23 -0
- data/features/step_definations/frame_steps.rb +189 -0
- data/features/step_definations/generic_element_steps.rb +31 -0
- data/features/step_definations/heading_steps.rb +39 -0
- data/features/step_definations/hidden_field_steps.rb +27 -0
- data/features/step_definations/image_steps.rb +35 -0
- data/features/step_definations/italic_steps.rb +11 -0
- data/features/step_definations/javasript_steps.rb +52 -0
- data/features/step_definations/label_steps.rb +19 -0
- data/features/step_definations/link_steps.rb +42 -0
- data/features/step_definations/list_item_steps.rb +24 -0
- data/features/step_definations/modal_dialog_steps.rb +38 -0
- data/features/step_definations/multi_elements_steps.rb +557 -0
- data/features/step_definations/nested_elements_steps.rb +219 -0
- data/features/step_definations/ordered_list_steps.rb +49 -0
- data/features/step_definations/page_level_actions_steps.rb +172 -0
- data/features/step_definations/page_traversal_steps.rb +4 -0
- data/features/step_definations/paragraph_steps.rb +19 -0
- data/features/step_definations/populate_page_with_steps.rb +3 -0
- data/features/step_definations/radio_button_group_steps.rb +32 -0
- data/features/step_definations/radio_button_steps.rb +31 -0
- data/features/step_definations/section_steps.rb +271 -0
- data/features/step_definations/select_list_steps.rb +91 -0
- data/features/step_definations/span_steps.rb +23 -0
- data/features/step_definations/table_cell_steps.rb +27 -0
- data/features/step_definations/table_row_steps.rb +23 -0
- data/features/step_definations/table_steps.rb +109 -0
- data/features/step_definations/text_area_steps.rb +39 -0
- data/features/step_definations/text_field_steps.rb +39 -0
- data/features/step_definations/unordered_list_steps.rb +27 -0
- data/features/step_definations/video_steps.rb +27 -0
- data/features/support/ajax_test_environment.rb +26 -0
- data/features/support/audio_video_page.rb +23 -0
- data/features/support/env.rb +5 -0
- data/features/support/hooks.rb +3 -0
- data/features/support/page.rb +372 -0
- data/features/support/persistent_browser.rb +58 -0
- data/features/support/targets/firefox14_osx.rb +5 -0
- data/features/support/targets/firefox14_windows7.rb +5 -0
- data/features/support/url_helper.rb +50 -0
- data/features/table.feature +127 -0
- data/features/table_cell.feature +42 -0
- data/features/table_row.feature +30 -0
- data/features/text_area.feature +44 -0
- data/features/text_field.feature +53 -0
- data/features/unordered_list.feature +46 -0
- data/features/video.feature +66 -0
- data/lib/druid/accessors.rb +1082 -0
- data/lib/druid/assist.rb +653 -0
- data/lib/druid/element_locators.rb +21 -0
- data/lib/druid/elements/area.rb +9 -0
- data/lib/druid/elements/audio.rb +9 -0
- data/lib/druid/elements/bold.rb +8 -0
- data/lib/druid/elements/button.rb +12 -0
- data/lib/druid/elements/canvas.rb +9 -0
- data/lib/druid/elements/check_box.rb +9 -0
- data/lib/druid/elements/div.rb +9 -0
- data/lib/druid/elements/element.rb +187 -0
- data/lib/druid/elements/file_field.rb +9 -0
- data/lib/druid/elements/form.rb +9 -0
- data/lib/druid/elements/heading.rb +14 -0
- data/lib/druid/elements/hidden_field.rb +9 -0
- data/lib/druid/elements/image.rb +9 -0
- data/lib/druid/elements/italic.rb +9 -0
- data/lib/druid/elements/label.rb +8 -0
- data/lib/druid/elements/link.rb +9 -0
- data/lib/druid/elements/list_item.rb +9 -0
- data/lib/druid/elements/media.rb +11 -0
- data/lib/druid/elements/option.rb +9 -0
- data/lib/druid/elements/ordered_list.rb +29 -0
- data/lib/druid/elements/paragraph.rb +9 -0
- data/lib/druid/elements/radio_button.rb +9 -0
- data/lib/druid/elements/select_list.rb +30 -0
- data/lib/druid/elements/span.rb +9 -0
- data/lib/druid/elements/table.rb +92 -0
- data/lib/druid/elements/table_cell.rb +11 -0
- data/lib/druid/elements/table_row.rb +50 -0
- data/lib/druid/elements/text_area.rb +10 -0
- data/lib/druid/elements/text_field.rb +11 -0
- data/lib/druid/elements/unordered_list.rb +32 -0
- data/lib/druid/elements/video.rb +8 -0
- data/lib/druid/elements.rb +55 -0
- data/lib/druid/javascript/angularjs.rb +12 -0
- data/lib/druid/javascript/jquery.rb +12 -0
- data/lib/druid/javascript/prototype.rb +12 -0
- data/lib/druid/javascript/yui.rb +19 -0
- data/lib/druid/javascript_framework_facade.rb +76 -0
- data/lib/druid/locator_generator.rb +181 -0
- data/lib/druid/nested_elements.rb +56 -0
- data/lib/druid/page_factory.rb +115 -0
- data/lib/druid/page_populator.rb +104 -0
- data/lib/druid/section_collection.rb +17 -0
- data/lib/druid/version.rb +3 -0
- data/lib/druid.rb +452 -0
- data/spec/druid/accessors_spec.rb +1209 -0
- data/spec/druid/druid_spec.rb +295 -0
- data/spec/druid/element_locators_spec.rb +750 -0
- data/spec/druid/elements/bold_spec.rb +12 -0
- data/spec/druid/elements/button_spec.rb +23 -0
- data/spec/druid/elements/check_box_spec.rb +14 -0
- data/spec/druid/elements/div_spec.rb +10 -0
- data/spec/druid/elements/element_spec.rb +250 -0
- data/spec/druid/elements/file_field_spec.rb +13 -0
- data/spec/druid/elements/form_spec.rb +18 -0
- data/spec/druid/elements/heading_spec.rb +30 -0
- data/spec/druid/elements/hidden_field_spec.rb +10 -0
- data/spec/druid/elements/image_spec.rb +23 -0
- data/spec/druid/elements/itatic_spec.rb +11 -0
- data/spec/druid/elements/label_spec.rb +10 -0
- data/spec/druid/elements/link_spec.rb +10 -0
- data/spec/druid/elements/list_item_spec.rb +10 -0
- data/spec/druid/elements/media_spec.rb +12 -0
- data/spec/druid/elements/option_spec.rb +21 -0
- data/spec/druid/elements/ordered_list_spec.rb +38 -0
- data/spec/druid/elements/page_factory_spec.rb +40 -0
- data/spec/druid/elements/paragraph_spec.rb +12 -0
- data/spec/druid/elements/radio_button_spec.rb +14 -0
- data/spec/druid/elements/select_list_spec.rb +51 -0
- data/spec/druid/elements/span_spec.rb +10 -0
- data/spec/druid/elements/table_cell_spec.rb +14 -0
- data/spec/druid/elements/table_row_spec.rb +34 -0
- data/spec/druid/elements/table_spec.rb +47 -0
- data/spec/druid/elements/text_area_spec.rb +13 -0
- data/spec/druid/elements/text_field_spec.rb +22 -0
- data/spec/druid/elements/unordered_list_spec.rb +39 -0
- data/spec/druid/javascript_framework_facade_spec.rb +59 -0
- data/spec/druid/nested_element_spec.rb +128 -0
- data/spec/druid/page_factory_spec.rb +235 -0
- data/spec/druid/page_populator_spec.rb +173 -0
- data/spec/druid/page_section_spec.rb +70 -0
- data/spec/spec_helper.rb +9 -0
- metadata +517 -0
|
@@ -0,0 +1,1209 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
class GenericPage
|
|
4
|
+
include Druid
|
|
5
|
+
|
|
6
|
+
wait_for_expected_title 'expected title'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class AccessorsTestDruid
|
|
10
|
+
include Druid
|
|
11
|
+
|
|
12
|
+
page_url "http://apple.com"
|
|
13
|
+
expected_title "Expected Title"
|
|
14
|
+
expected_element :google_search
|
|
15
|
+
link(:google_search, :link => 'Google Search')
|
|
16
|
+
text_field(:first_name, :id => 'first_name')
|
|
17
|
+
select_list(:state, :id => 'state')
|
|
18
|
+
checkbox(:active, :id => 'is_active_id')
|
|
19
|
+
button(:click_me, :id => 'button_submit')
|
|
20
|
+
radio_button(:first, :id => 'first_choice')
|
|
21
|
+
div(:message, :id => 'message_id')
|
|
22
|
+
table(:cart, :id => 'cart_id')
|
|
23
|
+
cell(:total, :id => 'total')
|
|
24
|
+
span(:alert_span, :id => 'alert_id')
|
|
25
|
+
image(:logo, :id => 'logo')
|
|
26
|
+
hidden_field(:social_security_number, :id => 'ssn')
|
|
27
|
+
form(:login, :id => 'login')
|
|
28
|
+
text_area(:address, :id => 'address')
|
|
29
|
+
list_item(:item_one, :id => 'one')
|
|
30
|
+
unordered_list(:menu, :id => 'main_menu')
|
|
31
|
+
ordered_list(:top_five, :id => 'top')
|
|
32
|
+
h1(:heading1, :id => 'main_heading')
|
|
33
|
+
h2(:heading2, :id => 'main_heading')
|
|
34
|
+
h3(:heading3, :id => 'main_heading')
|
|
35
|
+
h4(:heading4, :id => 'main_heading')
|
|
36
|
+
h5(:heading5, :id => 'main_heading')
|
|
37
|
+
h6(:heading6, :id => 'main_heading')
|
|
38
|
+
paragraph(:first_para, :id => 'first')
|
|
39
|
+
file_field(:upload_me, :id => 'the_file')
|
|
40
|
+
area(:img_area, :id => 'area')
|
|
41
|
+
canvas(:my_canvas, :id => 'canvas_id')
|
|
42
|
+
audio(:acdc, :id => 'audio_id')
|
|
43
|
+
video(:movie, :id => 'video_id')
|
|
44
|
+
b(:bold, :id => 'bold')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class BlockDruid
|
|
48
|
+
include Druid
|
|
49
|
+
|
|
50
|
+
text_field :first_name do |element|
|
|
51
|
+
"text_field"
|
|
52
|
+
end
|
|
53
|
+
hidden_field :secret do |element|
|
|
54
|
+
"hidden_field"
|
|
55
|
+
end
|
|
56
|
+
text_area :address do |element|
|
|
57
|
+
"text_area"
|
|
58
|
+
end
|
|
59
|
+
select_list :state do |element|
|
|
60
|
+
"select_list"
|
|
61
|
+
end
|
|
62
|
+
link :continue do |element|
|
|
63
|
+
"link"
|
|
64
|
+
end
|
|
65
|
+
checkbox :active do |element|
|
|
66
|
+
"checkbox"
|
|
67
|
+
end
|
|
68
|
+
radio_button :first do |element|
|
|
69
|
+
"radio_button"
|
|
70
|
+
end
|
|
71
|
+
button :click_me do |element|
|
|
72
|
+
"button"
|
|
73
|
+
end
|
|
74
|
+
div :footer do |element|
|
|
75
|
+
"div"
|
|
76
|
+
end
|
|
77
|
+
span :alert_span do |element|
|
|
78
|
+
"span"
|
|
79
|
+
end
|
|
80
|
+
table :cart do |element|
|
|
81
|
+
"table"
|
|
82
|
+
end
|
|
83
|
+
cell :total do |element|
|
|
84
|
+
"cell"
|
|
85
|
+
end
|
|
86
|
+
image :logo do |element|
|
|
87
|
+
"image"
|
|
88
|
+
end
|
|
89
|
+
form :login do |element|
|
|
90
|
+
"form"
|
|
91
|
+
end
|
|
92
|
+
list_item :item_one do |element|
|
|
93
|
+
"list_item"
|
|
94
|
+
end
|
|
95
|
+
unordered_list :menu do |element|
|
|
96
|
+
"unordered_list"
|
|
97
|
+
end
|
|
98
|
+
ordered_list :top_five do |element|
|
|
99
|
+
"ordered_list"
|
|
100
|
+
end
|
|
101
|
+
h1 :heading1 do |element|
|
|
102
|
+
"h1"
|
|
103
|
+
end
|
|
104
|
+
h2 :heading2 do |element|
|
|
105
|
+
"h2"
|
|
106
|
+
end
|
|
107
|
+
h3 :heading3 do |element|
|
|
108
|
+
"h3"
|
|
109
|
+
end
|
|
110
|
+
h4 :heading4 do |element|
|
|
111
|
+
"h4"
|
|
112
|
+
end
|
|
113
|
+
h5 :heading5 do |element|
|
|
114
|
+
"h5"
|
|
115
|
+
end
|
|
116
|
+
h6 :heading6 do |element|
|
|
117
|
+
"h6"
|
|
118
|
+
end
|
|
119
|
+
paragraph :first_para do |element|
|
|
120
|
+
"p"
|
|
121
|
+
end
|
|
122
|
+
file_field :a_file do |element|
|
|
123
|
+
"file_field"
|
|
124
|
+
end
|
|
125
|
+
area :img_area do |element|
|
|
126
|
+
"area"
|
|
127
|
+
end
|
|
128
|
+
canvas :my_canvas do |element|
|
|
129
|
+
"canvas"
|
|
130
|
+
end
|
|
131
|
+
audio :acdc do |element|
|
|
132
|
+
"audio"
|
|
133
|
+
end
|
|
134
|
+
video :movie do |element|
|
|
135
|
+
"video"
|
|
136
|
+
end
|
|
137
|
+
b :bold do |element|
|
|
138
|
+
"b"
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
class TestDruidBackUp
|
|
143
|
+
include Druid
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
describe Druid::Accessors do
|
|
147
|
+
let(:driver) { mock_driver }
|
|
148
|
+
let(:druid) { AccessorsTestDruid.new(driver) }
|
|
149
|
+
let(:block_druid) { BlockDruid.new(driver) }
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
describe "goto a page" do
|
|
153
|
+
it "should navigate to a page when requested" do
|
|
154
|
+
expect(driver).to receive(:goto)
|
|
155
|
+
AccessorsTestDruid.new(driver, true)
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "should call a method when page_url called with a symbol" do
|
|
159
|
+
class SymbolPageUrl
|
|
160
|
+
include Druid
|
|
161
|
+
page_url :custom_url
|
|
162
|
+
|
|
163
|
+
attr_reader :custom_url
|
|
164
|
+
|
|
165
|
+
def initialize(d, v, url)
|
|
166
|
+
@custom_url = url
|
|
167
|
+
super(d, v)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
expect(driver).to receive(:goto).with("custom")
|
|
171
|
+
SymbolPageUrl.new(driver, true, 'custom')
|
|
172
|
+
expect(driver).to receive(:goto).with('different')
|
|
173
|
+
SymbolPageUrl.new(driver, true, 'different')
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "should not navigate to a page when not requested" do
|
|
177
|
+
expect(driver).not_to receive(:goto)
|
|
178
|
+
AccessorsTestDruid.new(driver)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it "should not navigate to a page when 'page_url' not specified" do
|
|
182
|
+
expect(driver).not_to receive(:goto)
|
|
183
|
+
TestDruidBackUp.new(driver,true)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it "should provide the page url" do
|
|
187
|
+
expect(druid.page_url_value).to eql "http://apple.com"
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
describe "validating the page title" do
|
|
192
|
+
it "should validate the title" do
|
|
193
|
+
expect(driver).to receive(:title).and_return("Expected Title")
|
|
194
|
+
expect(druid).to have_expected_title
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it "should validate the by regexp" do
|
|
198
|
+
class RegexpExpectedTitle
|
|
199
|
+
include Druid
|
|
200
|
+
expected_title /\w+ \w+/
|
|
201
|
+
end
|
|
202
|
+
expect(driver).to receive(:title).and_return("Expected Title")
|
|
203
|
+
expect(RegexpExpectedTitle.new(driver)).to have_expected_title
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it "should raise error when it does not have expected title" do
|
|
207
|
+
expect(driver).to receive(:title).and_return("Not Expected")
|
|
208
|
+
expect {druid.has_expected_title? }.to raise_error "Expected title \'Expected Title\' instead of \'Not Expected\'"
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
describe "validating the existence of an element" do
|
|
213
|
+
it "should validate an element exists" do
|
|
214
|
+
allow(druid).to receive(:google_search_element).and_return(driver)
|
|
215
|
+
allow(driver).to receive(:when_present).and_return(true)
|
|
216
|
+
druid.has_expected_element?
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it "should handle non-existent elements gracefully" do
|
|
220
|
+
class FakePage
|
|
221
|
+
include Druid
|
|
222
|
+
expected_element :foo
|
|
223
|
+
end
|
|
224
|
+
expect(FakePage.new(driver)).not_to have_expected_element
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
context "using element accessor" do
|
|
229
|
+
class DefaultElementTagToElement
|
|
230
|
+
include Druid
|
|
231
|
+
# verify that the explicit :element tag can be omitted
|
|
232
|
+
# element('button', :element, {:css => 'some css'})
|
|
233
|
+
element('button', { :css => 'some css' })
|
|
234
|
+
elements('button2', { :css => 'some css' })
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
let(:page) { DefaultElementTagToElement.new(driver) }
|
|
238
|
+
|
|
239
|
+
def mock_driver_for(tag)
|
|
240
|
+
expect(driver).to receive(tag).with(:css => 'some css').and_return(driver)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it "should default element tag to element" do
|
|
244
|
+
mock_driver_for :element
|
|
245
|
+
page.button_element
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
it "should default elements tag to element" do
|
|
249
|
+
mock_driver_for :elements
|
|
250
|
+
expect(driver).to receive(:map).and_return([])
|
|
251
|
+
page.button2_elements.to_a
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
describe "using default identifiers" do
|
|
256
|
+
class DefaultIdentifier
|
|
257
|
+
include Druid
|
|
258
|
+
text_field(:default_tf)
|
|
259
|
+
hidden_field(:default_hf)
|
|
260
|
+
text_area(:default_ta)
|
|
261
|
+
select_list(:default_sl)
|
|
262
|
+
link(:default_link)
|
|
263
|
+
checkbox(:default_cb)
|
|
264
|
+
radio_button(:default_rb)
|
|
265
|
+
button(:default_but)
|
|
266
|
+
div(:default_div)
|
|
267
|
+
span(:default_span)
|
|
268
|
+
table(:default_tab)
|
|
269
|
+
cell(:default_cell)
|
|
270
|
+
image(:default_im)
|
|
271
|
+
form(:default_form)
|
|
272
|
+
list_item(:default_li)
|
|
273
|
+
unordered_list(:default_ul)
|
|
274
|
+
ordered_list(:default_ol)
|
|
275
|
+
h1(:default_h1)
|
|
276
|
+
h2(:default_h2)
|
|
277
|
+
h3(:default_h3)
|
|
278
|
+
h4(:default_h4)
|
|
279
|
+
h5(:default_h5)
|
|
280
|
+
h6(:default_h6)
|
|
281
|
+
paragraph(:default_p)
|
|
282
|
+
file_field(:default_ff)
|
|
283
|
+
label(:default_lab)
|
|
284
|
+
element(:default_el, :audio)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
let(:default_identifier) { DefaultIdentifier.new(driver) }
|
|
288
|
+
|
|
289
|
+
before(:each) do
|
|
290
|
+
expect(driver).to receive(:exist?).and_return(true)
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def mock_driver_for(tag)
|
|
294
|
+
expect(driver).to receive(tag).with(:index => 0).and_return(driver)
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
it "should work with a text_field" do
|
|
298
|
+
mock_driver_for :text_field
|
|
299
|
+
default_identifier.default_tf?
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
it "should work with a hidden field" do
|
|
303
|
+
mock_driver_for :hidden
|
|
304
|
+
default_identifier.default_hf?
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
it "should work with a text area" do
|
|
308
|
+
mock_driver_for :textarea
|
|
309
|
+
default_identifier.default_ta?
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
it "should work with a select list" do
|
|
313
|
+
mock_driver_for :select_list
|
|
314
|
+
default_identifier.default_sl?
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
it "should work with a link" do
|
|
318
|
+
mock_driver_for :link
|
|
319
|
+
default_identifier.default_link?
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
it "should work with a checkbox" do
|
|
323
|
+
mock_driver_for :checkbox
|
|
324
|
+
default_identifier.default_cb?
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
it "should work with a radio button" do
|
|
328
|
+
mock_driver_for :radio
|
|
329
|
+
default_identifier.default_rb?
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
it "should work with a button" do
|
|
333
|
+
mock_driver_for :button
|
|
334
|
+
default_identifier.default_but?
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
it "should work with a div" do
|
|
338
|
+
mock_driver_for :div
|
|
339
|
+
default_identifier.default_div?
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
it "should work with a span" do
|
|
343
|
+
mock_driver_for :span
|
|
344
|
+
default_identifier.default_span?
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
it "should work with a table" do
|
|
348
|
+
mock_driver_for :table
|
|
349
|
+
default_identifier.default_tab?
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
it "should work with a cell" do
|
|
353
|
+
mock_driver_for :td
|
|
354
|
+
default_identifier.default_cell?
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
it "should work with an image" do
|
|
358
|
+
mock_driver_for :image
|
|
359
|
+
default_identifier.default_im?
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
it "should work with a form" do
|
|
363
|
+
mock_driver_for :form
|
|
364
|
+
default_identifier.default_form?
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
it "should work with a list item" do
|
|
368
|
+
mock_driver_for :li
|
|
369
|
+
default_identifier.default_li?
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
it "should work with unordered lists" do
|
|
373
|
+
mock_driver_for :ul
|
|
374
|
+
default_identifier.default_ul?
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
it "should work with ordered lists" do
|
|
378
|
+
mock_driver_for :ol
|
|
379
|
+
default_identifier.default_ol?
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
it "should work with h1" do
|
|
383
|
+
mock_driver_for :h1
|
|
384
|
+
default_identifier.default_h1?
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
it "should work with h2" do
|
|
388
|
+
mock_driver_for :h2
|
|
389
|
+
default_identifier.default_h2?
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
it "should work with h3" do
|
|
393
|
+
mock_driver_for :h3
|
|
394
|
+
default_identifier.default_h3?
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
it "should work with h4" do
|
|
398
|
+
mock_driver_for :h4
|
|
399
|
+
default_identifier.default_h4?
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
it "should work with h5" do
|
|
403
|
+
mock_driver_for :h5
|
|
404
|
+
default_identifier.default_h5?
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
it "should work with h6" do
|
|
408
|
+
mock_driver_for :h6
|
|
409
|
+
default_identifier.default_h6?
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
it "should work with paragraph" do
|
|
413
|
+
mock_driver_for :p
|
|
414
|
+
default_identifier.default_p?
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
it "should work with file_field" do
|
|
418
|
+
mock_driver_for :file_field
|
|
419
|
+
default_identifier.default_ff?
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
it "should work with a label" do
|
|
423
|
+
mock_driver_for :label
|
|
424
|
+
default_identifier.default_lab?
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
it "should work with an element" do
|
|
428
|
+
mock_driver_for :audio
|
|
429
|
+
default_identifier.default_el?
|
|
430
|
+
end
|
|
431
|
+
end
|
|
432
|
+
|
|
433
|
+
describe "check_box accessors" do
|
|
434
|
+
context "when called on a page object" do
|
|
435
|
+
it "should generate accessor methods" do
|
|
436
|
+
expect(druid).to respond_to :check_active
|
|
437
|
+
expect(druid).to respond_to :uncheck_active
|
|
438
|
+
expect(druid).to respond_to :active_checked?
|
|
439
|
+
expect(druid).to respond_to :active_element
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
it "should call a block on the element method when present" do
|
|
443
|
+
expect(block_druid.active_element).to eql "checkbox"
|
|
444
|
+
end
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
context "implementation" do
|
|
448
|
+
it "should check a check box element" do
|
|
449
|
+
expect(driver).to receive_message_chain(:checkbox, :set)
|
|
450
|
+
druid.check_active
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
it "should clear a check box element" do
|
|
454
|
+
expect(driver).to receive_message_chain(:checkbox, :clear)
|
|
455
|
+
druid.uncheck_active
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it "should know if a check box element is selected" do
|
|
459
|
+
expect(driver).to receive_message_chain(:checkbox, :set?).and_return(true)
|
|
460
|
+
expect(druid.active_checked?).to be true
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
it "should retreive a check box element" do
|
|
464
|
+
expect(driver).to receive(:checkbox)
|
|
465
|
+
expect(druid.active_element).to be_instance_of Druid::Elements::CheckBox
|
|
466
|
+
end
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
describe "link accessors" do
|
|
471
|
+
|
|
472
|
+
context "when called on a page object" do
|
|
473
|
+
it "should generate accessor methods" do
|
|
474
|
+
expect(druid).to respond_to(:google_search)
|
|
475
|
+
expect(druid).to respond_to(:google_search_element)
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
it "should call a block on the element method when present" do
|
|
479
|
+
expect(block_druid.continue_element).to eql "link"
|
|
480
|
+
end
|
|
481
|
+
end
|
|
482
|
+
|
|
483
|
+
context "implementation" do
|
|
484
|
+
it "should select a link" do
|
|
485
|
+
expect(driver).to receive_message_chain(:link, :click)
|
|
486
|
+
druid.google_search
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
it "should retreive a link element" do
|
|
490
|
+
expect(driver).to receive(:link)
|
|
491
|
+
expect(druid.google_search_element).to be_instance_of Druid::Elements::Link
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
describe "select_list accessors" do
|
|
497
|
+
|
|
498
|
+
context "when called on a page object" do
|
|
499
|
+
it "should generate accessor methods" do
|
|
500
|
+
expect(druid).to respond_to :state
|
|
501
|
+
expect(druid).to respond_to :state=
|
|
502
|
+
expect(druid).to respond_to :state_element
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
it "should call a block on the element method when present" do
|
|
506
|
+
expect(block_druid.state_element).to eql "select_list"
|
|
507
|
+
end
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
context "implementation" do
|
|
511
|
+
it "should get the current item from a select list" do
|
|
512
|
+
expect(driver).to receive(:select_list).and_return(driver)
|
|
513
|
+
expect(driver).to receive(:selected_options).and_return [driver]
|
|
514
|
+
expect(driver).to receive(:text).and_return('OH')
|
|
515
|
+
expect(druid.state).to eql 'OH'
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
it "should set the current item fo a select list" do
|
|
519
|
+
expect(driver).to receive(:select_list).and_return driver
|
|
520
|
+
expect(driver).to receive(:select).with('OH')
|
|
521
|
+
druid.state = 'OH'
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
it "should retreive a select list element" do
|
|
525
|
+
expect(driver).to receive(:select_list)
|
|
526
|
+
expect(druid.state_element).to be_instance_of Druid::Elements::SelectList
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
it "should return list of selection options" do
|
|
530
|
+
option1 = double('option')
|
|
531
|
+
option2 = double('option')
|
|
532
|
+
expect(option1).to receive(:text).and_return("CA")
|
|
533
|
+
expect(option2).to receive(:text).and_return('OH')
|
|
534
|
+
select_element = double("select")
|
|
535
|
+
expect(select_element).to receive(:options).twice.and_return([option1,option2])
|
|
536
|
+
expect(druid).to receive(:state_element).and_return(select_element)
|
|
537
|
+
expect(druid.state_options).to eql ["CA","OH"]
|
|
538
|
+
end
|
|
539
|
+
end
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
describe "text_field accessors" do
|
|
543
|
+
|
|
544
|
+
context "when called on a page object" do
|
|
545
|
+
it "should generate accessor methods" do
|
|
546
|
+
expect(druid).to respond_to(:first_name)
|
|
547
|
+
expect(druid).to respond_to(:first_name=)
|
|
548
|
+
expect(druid).to respond_to(:first_name_element)
|
|
549
|
+
expect(druid).to respond_to(:first_name?)
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
it "should call a block on the element method when present" do
|
|
553
|
+
expect(block_druid.first_name_element).to eql "text_field"
|
|
554
|
+
end
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
context "implementation" do
|
|
558
|
+
it "should get the text from the text field element" do
|
|
559
|
+
expect(driver).to receive_message_chain(:text_field, :value).and_return('Kim')
|
|
560
|
+
expect(druid.first_name).to eql 'Kim'
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
it "should set some text on a text field element" do
|
|
564
|
+
expect(driver).to receive_message_chain(:text_field, :set).with('Kim')
|
|
565
|
+
druid.first_name = 'Kim'
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
it "should retreive text field element" do
|
|
569
|
+
expect(driver).to receive(:text_field)
|
|
570
|
+
expect(druid.first_name_element).to be_instance_of Druid::Elements::TextField
|
|
571
|
+
end
|
|
572
|
+
end
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
describe "button accessors" do
|
|
576
|
+
context "when called on a page object" do
|
|
577
|
+
it "should generate accessor methods" do
|
|
578
|
+
expect(druid).to respond_to :click_me
|
|
579
|
+
expect(druid).to respond_to :click_me_element
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
it "should call a block on the element method when present" do
|
|
583
|
+
expect(block_druid.click_me_element).to eql "button"
|
|
584
|
+
end
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
context "implementation" do
|
|
588
|
+
it "should select a button" do
|
|
589
|
+
expect(driver).to receive_message_chain(:button, :click)
|
|
590
|
+
druid.click_me
|
|
591
|
+
end
|
|
592
|
+
|
|
593
|
+
it "should retreive a button element" do
|
|
594
|
+
expect(driver).to receive(:button)
|
|
595
|
+
expect(druid.click_me_element).to be_instance_of Druid::Elements::Button
|
|
596
|
+
end
|
|
597
|
+
end
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
describe "radio accessors" do
|
|
601
|
+
context "when called on a page object" do
|
|
602
|
+
it "should generate accessor methods" do
|
|
603
|
+
expect(druid).to respond_to :first_element
|
|
604
|
+
expect(druid).to respond_to :select_first
|
|
605
|
+
expect(druid).to respond_to :first_selected?
|
|
606
|
+
end
|
|
607
|
+
|
|
608
|
+
it "should call a block on the element method when present" do
|
|
609
|
+
expect(block_druid.first_element).to eql "radio_button"
|
|
610
|
+
end
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
context "implementation" do
|
|
614
|
+
it "should select a radio button" do
|
|
615
|
+
expect(driver).to receive_message_chain(:radio, :set)
|
|
616
|
+
druid.select_first
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
it "should determine if a radio is selected" do
|
|
620
|
+
expect(driver).to receive_message_chain(:radio, :set?).and_return(true)
|
|
621
|
+
expect(druid.first_selected?).to be true
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
it "should retreive a radio button element" do
|
|
625
|
+
expect(driver).to receive(:radio)
|
|
626
|
+
expect(druid.first_element).to be_instance_of Druid::Elements::RadioButton
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
describe "div accessors" do
|
|
632
|
+
context "when called on a page object" do
|
|
633
|
+
it "should generate accessor methods" do
|
|
634
|
+
expect(druid).to respond_to :message
|
|
635
|
+
expect(druid).to respond_to :message_element
|
|
636
|
+
end
|
|
637
|
+
|
|
638
|
+
it "should call a block on the element method when present" do
|
|
639
|
+
expect(block_druid.footer_element).to eql "div"
|
|
640
|
+
end
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
context "implementation" do
|
|
644
|
+
it "should retreive the text from a div" do
|
|
645
|
+
expect(driver).to receive_message_chain(:div, :text).and_return("Message from div")
|
|
646
|
+
expect(druid.message).to eql "Message from div"
|
|
647
|
+
end
|
|
648
|
+
|
|
649
|
+
it "should retreive a div element" do
|
|
650
|
+
expect(driver).to receive(:div)
|
|
651
|
+
expect(druid.message_element).to be_instance_of Druid::Elements::Div
|
|
652
|
+
end
|
|
653
|
+
end
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
describe "table accessors" do
|
|
657
|
+
context "when called on a page object" do
|
|
658
|
+
it "should generate accessor methods" do
|
|
659
|
+
expect(druid).to respond_to :cart_element
|
|
660
|
+
end
|
|
661
|
+
|
|
662
|
+
it "should call a block on the element method when present" do
|
|
663
|
+
expect(block_druid.cart_element).to eql "table"
|
|
664
|
+
end
|
|
665
|
+
end
|
|
666
|
+
|
|
667
|
+
context "implementation" do
|
|
668
|
+
it "should retrieve the table element from the page" do
|
|
669
|
+
expect(driver).to receive(:table)
|
|
670
|
+
expect(druid.cart_element).to be_instance_of Druid::Elements::Table
|
|
671
|
+
end
|
|
672
|
+
end
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
describe "table cell accessors" do
|
|
676
|
+
context "when called on a page object" do
|
|
677
|
+
it "should generate accessor methods" do
|
|
678
|
+
expect(druid).to respond_to :total
|
|
679
|
+
expect(druid).to respond_to :total_element
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
it "should call a block on the element method when present" do
|
|
683
|
+
expect(block_druid.total_element).to eql "cell"
|
|
684
|
+
end
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
context "implementation" do
|
|
688
|
+
it "should retrieve the text from the cell" do
|
|
689
|
+
expect(driver).to receive_message_chain(:td, :text).and_return("10.00")
|
|
690
|
+
expect(druid.total).to eql "10.00"
|
|
691
|
+
end
|
|
692
|
+
|
|
693
|
+
it "should retrieve the cell element from the page" do
|
|
694
|
+
expect(driver).to receive(:td)
|
|
695
|
+
expect(druid.total_element).to be_instance_of Druid::Elements::TableCell
|
|
696
|
+
end
|
|
697
|
+
end
|
|
698
|
+
end
|
|
699
|
+
|
|
700
|
+
describe "span accessors" do
|
|
701
|
+
context "when called on a page object" do
|
|
702
|
+
it "should generate accessor methods" do
|
|
703
|
+
expect(druid).to respond_to :alert_span
|
|
704
|
+
expect(druid).to respond_to :alert_span_element
|
|
705
|
+
end
|
|
706
|
+
|
|
707
|
+
it "should call a block on the element method when present" do
|
|
708
|
+
expect(block_druid.alert_span_element).to eql "span"
|
|
709
|
+
end
|
|
710
|
+
end
|
|
711
|
+
|
|
712
|
+
context "implementation" do
|
|
713
|
+
it "should retrieve the text from a span" do
|
|
714
|
+
expect(driver).to receive_message_chain(:span, :text).and_return('Alert')
|
|
715
|
+
expect(druid.alert_span).to eql 'Alert'
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
it "should retrieve the span element from the page" do
|
|
719
|
+
expect(driver).to receive(:span)
|
|
720
|
+
expect(druid.alert_span_element).to be_instance_of Druid::Elements::Span
|
|
721
|
+
end
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
describe "image accessors" do
|
|
726
|
+
context "when called on a page object" do
|
|
727
|
+
it "should generate accessor methods" do
|
|
728
|
+
expect(druid).to respond_to :logo_element
|
|
729
|
+
expect(druid).to respond_to :logo_loaded?
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
it "should call a block on the element method when present " do
|
|
733
|
+
expect(block_druid.logo_element).to eql "image"
|
|
734
|
+
end
|
|
735
|
+
end
|
|
736
|
+
|
|
737
|
+
context "implementation" do
|
|
738
|
+
it "should retrieve the image element from the page" do
|
|
739
|
+
expect(driver).to receive(:image)
|
|
740
|
+
expect(druid.logo_element).to be_instance_of Druid::Elements::Image
|
|
741
|
+
end
|
|
742
|
+
end
|
|
743
|
+
end
|
|
744
|
+
|
|
745
|
+
describe "hidden field accessors" do
|
|
746
|
+
context "when called on a page object" do
|
|
747
|
+
it "should generate accessor methods" do
|
|
748
|
+
expect(druid).to respond_to :social_security_number
|
|
749
|
+
expect(druid).to respond_to :social_security_number_element
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
it "should call a block on the element method when present" do
|
|
753
|
+
expect(block_druid.secret_element).to eql "hidden_field"
|
|
754
|
+
end
|
|
755
|
+
end
|
|
756
|
+
|
|
757
|
+
context "implementation" do
|
|
758
|
+
it "should get the text from a hidden field" do
|
|
759
|
+
expect(driver).to receive_message_chain(:hidden, :value).and_return('value')
|
|
760
|
+
expect(druid.social_security_number).to eql 'value'
|
|
761
|
+
end
|
|
762
|
+
|
|
763
|
+
it "should retrieve a hidden field element" do
|
|
764
|
+
expect(driver).to receive(:hidden)
|
|
765
|
+
expect(druid.social_security_number_element).to be_instance_of Druid::Elements::HiddenField
|
|
766
|
+
end
|
|
767
|
+
end
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
describe "form accessors" do
|
|
771
|
+
context "when called on a page object" do
|
|
772
|
+
it "should generate accessor methods" do
|
|
773
|
+
expect(druid).to respond_to :login_element
|
|
774
|
+
end
|
|
775
|
+
|
|
776
|
+
it "should call a block on the element method when present" do
|
|
777
|
+
expect(block_druid.login_element).to eql "form"
|
|
778
|
+
end
|
|
779
|
+
end
|
|
780
|
+
|
|
781
|
+
context "implementation" do
|
|
782
|
+
it "should retrieve the form element from the page" do
|
|
783
|
+
expect(driver).to receive(:form)
|
|
784
|
+
expect(druid.login_element).to be_instance_of Druid::Elements::Form
|
|
785
|
+
end
|
|
786
|
+
end
|
|
787
|
+
end
|
|
788
|
+
|
|
789
|
+
describe "text area accessors" do
|
|
790
|
+
context "when called on a page object" do
|
|
791
|
+
it "should generate accessor methods" do
|
|
792
|
+
expect(druid).to respond_to :address
|
|
793
|
+
expect(druid).to respond_to :address=
|
|
794
|
+
expect(druid).to respond_to :address_element
|
|
795
|
+
end
|
|
796
|
+
|
|
797
|
+
it "should call a block on the element method when present" do
|
|
798
|
+
expect(block_druid.address_element).to eql "text_area"
|
|
799
|
+
end
|
|
800
|
+
end
|
|
801
|
+
|
|
802
|
+
context "implementation" do
|
|
803
|
+
it "should set some text on the text area" do
|
|
804
|
+
expect(driver).to receive_message_chain(:textarea, :set).with('123 main street')
|
|
805
|
+
druid.address='123 main street'
|
|
806
|
+
end
|
|
807
|
+
|
|
808
|
+
it "should get the text from the text area" do
|
|
809
|
+
expect(driver).to receive_message_chain(:textarea, :value).and_return('123 main street')
|
|
810
|
+
expect(druid.address).to eql '123 main street'
|
|
811
|
+
end
|
|
812
|
+
|
|
813
|
+
it "should retrieve a text area element" do
|
|
814
|
+
expect(driver).to receive(:textarea)
|
|
815
|
+
expect(druid.address_element).to be_instance_of Druid::Elements::TextArea
|
|
816
|
+
end
|
|
817
|
+
end
|
|
818
|
+
end
|
|
819
|
+
|
|
820
|
+
describe "list item accessors" do
|
|
821
|
+
context "when called on a page object" do
|
|
822
|
+
it "should generate accessor methods" do
|
|
823
|
+
expect(druid).to respond_to :item_one
|
|
824
|
+
expect(druid).to respond_to :item_one_element
|
|
825
|
+
end
|
|
826
|
+
|
|
827
|
+
it "should call a block on the element method when present" do
|
|
828
|
+
expect(block_druid.item_one_element).to eql "list_item"
|
|
829
|
+
end
|
|
830
|
+
end
|
|
831
|
+
|
|
832
|
+
context "implementation" do
|
|
833
|
+
it "should retrieve the text from the list item" do
|
|
834
|
+
expect(driver).to receive_message_chain(:li, :text).and_return('value')
|
|
835
|
+
expect(druid.item_one).to eql 'value'
|
|
836
|
+
end
|
|
837
|
+
|
|
838
|
+
it "should retrieve the list item element from the page" do
|
|
839
|
+
expect(driver).to receive(:li)
|
|
840
|
+
expect(druid.item_one_element).to be_instance_of Druid::Elements::ListItem
|
|
841
|
+
end
|
|
842
|
+
end
|
|
843
|
+
end
|
|
844
|
+
|
|
845
|
+
describe "unordered list accessors" do
|
|
846
|
+
context "when called on a page object" do
|
|
847
|
+
it "should generate accessor methods" do
|
|
848
|
+
expect(druid).to respond_to :menu_element
|
|
849
|
+
end
|
|
850
|
+
|
|
851
|
+
it "should call a block on the element method when present" do
|
|
852
|
+
expect(block_druid.menu_element).to eql "unordered_list"
|
|
853
|
+
end
|
|
854
|
+
end
|
|
855
|
+
|
|
856
|
+
context "implementation" do
|
|
857
|
+
it "should retrieve the element from the page" do
|
|
858
|
+
expect(driver).to receive(:ul)
|
|
859
|
+
expect(druid.menu_element).to be_instance_of Druid::Elements::UnOrderedList
|
|
860
|
+
end
|
|
861
|
+
end
|
|
862
|
+
end
|
|
863
|
+
|
|
864
|
+
describe "ordered list accessors" do
|
|
865
|
+
context "when called on a page object" do
|
|
866
|
+
it "should generate accessor methods" do
|
|
867
|
+
expect(druid).to respond_to :top_five_element
|
|
868
|
+
end
|
|
869
|
+
|
|
870
|
+
it "should call a block on the element method when present" do
|
|
871
|
+
expect(block_druid.top_five_element).to eql "ordered_list"
|
|
872
|
+
end
|
|
873
|
+
end
|
|
874
|
+
|
|
875
|
+
context "implementation" do
|
|
876
|
+
it "should retrieve the element from the page" do
|
|
877
|
+
expect(driver).to receive(:ol)
|
|
878
|
+
expect(druid.top_five_element).to be_instance_of Druid::Elements::OrderedList
|
|
879
|
+
end
|
|
880
|
+
end
|
|
881
|
+
end
|
|
882
|
+
|
|
883
|
+
describe "h1 accessors" do
|
|
884
|
+
context "when called on a page object" do
|
|
885
|
+
it "should generate accessor methods" do
|
|
886
|
+
expect(druid).to respond_to :heading1
|
|
887
|
+
expect(druid).to respond_to :heading1_element
|
|
888
|
+
end
|
|
889
|
+
|
|
890
|
+
it "should call a block on the element method when present" do
|
|
891
|
+
expect(block_druid.heading1_element).to eql "h1"
|
|
892
|
+
end
|
|
893
|
+
end
|
|
894
|
+
|
|
895
|
+
context "implementation" do
|
|
896
|
+
it "should retrieve the text from the h1" do
|
|
897
|
+
expect(driver).to receive(:h1).and_return(driver)
|
|
898
|
+
expect(driver).to receive(:text).and_return("value")
|
|
899
|
+
expect(druid.heading1).to eql "value"
|
|
900
|
+
end
|
|
901
|
+
|
|
902
|
+
it "should retrieve the element from the page" do
|
|
903
|
+
expect(driver).to receive(:h1).and_return(driver)
|
|
904
|
+
expect(druid.heading1_element).to be_instance_of Druid::Elements::Heading
|
|
905
|
+
end
|
|
906
|
+
end
|
|
907
|
+
end
|
|
908
|
+
|
|
909
|
+
describe "h2 accessors" do
|
|
910
|
+
context "when called on a page object" do
|
|
911
|
+
it "should generate accessor methods" do
|
|
912
|
+
expect(druid).to respond_to(:heading2)
|
|
913
|
+
expect(druid).to respond_to(:heading2_element)
|
|
914
|
+
end
|
|
915
|
+
|
|
916
|
+
it "should call a block on the element method when present" do
|
|
917
|
+
expect(block_druid.heading2_element).to eql "h2"
|
|
918
|
+
end
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
context "implementation" do
|
|
922
|
+
it "should retrieve the text from the h2" do
|
|
923
|
+
expect(driver).to receive(:h2).and_return(driver)
|
|
924
|
+
expect(driver).to receive(:text).and_return("value")
|
|
925
|
+
expect(druid.heading2).to eql "value"
|
|
926
|
+
end
|
|
927
|
+
|
|
928
|
+
it "should retrieve the element from the page" do
|
|
929
|
+
expect(driver).to receive(:h2).and_return(driver)
|
|
930
|
+
expect(druid.heading2_element).to be_instance_of Druid::Elements::Heading
|
|
931
|
+
end
|
|
932
|
+
end
|
|
933
|
+
end
|
|
934
|
+
|
|
935
|
+
describe "h3 accessors" do
|
|
936
|
+
context "when called on a page object" do
|
|
937
|
+
it "should generate accessor methods" do
|
|
938
|
+
expect(druid).to respond_to(:heading3)
|
|
939
|
+
expect(druid).to respond_to(:heading3_element)
|
|
940
|
+
end
|
|
941
|
+
|
|
942
|
+
it "should call a block on the element method when present" do
|
|
943
|
+
expect(block_druid.heading3_element).to eql "h3"
|
|
944
|
+
end
|
|
945
|
+
end
|
|
946
|
+
|
|
947
|
+
context "implementation" do
|
|
948
|
+
it "should retrieve the text from the h3" do
|
|
949
|
+
expect(driver).to receive(:h3).and_return(driver)
|
|
950
|
+
expect(driver).to receive(:text).and_return("value")
|
|
951
|
+
expect(druid.heading3).to eql "value"
|
|
952
|
+
end
|
|
953
|
+
|
|
954
|
+
it "should retrieve the element from the page" do
|
|
955
|
+
expect(driver).to receive(:h3).and_return(driver)
|
|
956
|
+
expect(druid.heading3_element).to be_instance_of Druid::Elements::Heading
|
|
957
|
+
end
|
|
958
|
+
end
|
|
959
|
+
end
|
|
960
|
+
|
|
961
|
+
describe "h4 accessors" do
|
|
962
|
+
context "when called on a page object" do
|
|
963
|
+
it "should generate accessor methods" do
|
|
964
|
+
expect(druid).to respond_to(:heading4)
|
|
965
|
+
expect(druid).to respond_to(:heading4_element)
|
|
966
|
+
end
|
|
967
|
+
|
|
968
|
+
it "should call a block on the element method when present" do
|
|
969
|
+
expect(block_druid.heading4_element).to eql "h4"
|
|
970
|
+
end
|
|
971
|
+
end
|
|
972
|
+
|
|
973
|
+
context "implementation" do
|
|
974
|
+
it "should retrieve the text from the h4" do
|
|
975
|
+
expect(driver).to receive(:h4).and_return(driver)
|
|
976
|
+
expect(driver).to receive(:text).and_return("value")
|
|
977
|
+
expect(druid.heading4).to eql "value"
|
|
978
|
+
end
|
|
979
|
+
|
|
980
|
+
it "should retrieve the element from the page" do
|
|
981
|
+
expect(driver).to receive(:h4).and_return(driver)
|
|
982
|
+
expect(druid.heading4_element).to be_instance_of Druid::Elements::Heading
|
|
983
|
+
end
|
|
984
|
+
end
|
|
985
|
+
end
|
|
986
|
+
|
|
987
|
+
describe "h5 accessors" do
|
|
988
|
+
context "when called on a page object" do
|
|
989
|
+
it "should generate accessor methods" do
|
|
990
|
+
expect(druid).to respond_to(:heading5)
|
|
991
|
+
expect(druid).to respond_to(:heading5_element)
|
|
992
|
+
end
|
|
993
|
+
|
|
994
|
+
it "should call a block on the element method present" do
|
|
995
|
+
expect(block_druid.heading5_element).to eql "h5"
|
|
996
|
+
end
|
|
997
|
+
end
|
|
998
|
+
|
|
999
|
+
context "implementation" do
|
|
1000
|
+
it "should retrieve the text from the h5" do
|
|
1001
|
+
expect(driver).to receive(:h5).and_return(driver)
|
|
1002
|
+
expect(driver).to receive(:text).and_return("value")
|
|
1003
|
+
expect(druid.heading5).to eql "value"
|
|
1004
|
+
end
|
|
1005
|
+
|
|
1006
|
+
it "should retrieve the element from the page" do
|
|
1007
|
+
expect(driver).to receive(:h5).and_return(driver)
|
|
1008
|
+
expect(druid.heading5_element).to be_instance_of Druid::Elements::Heading
|
|
1009
|
+
end
|
|
1010
|
+
end
|
|
1011
|
+
end
|
|
1012
|
+
|
|
1013
|
+
describe "h6 accessors" do
|
|
1014
|
+
context "when called on a page object" do
|
|
1015
|
+
it "should generate accessor methods" do
|
|
1016
|
+
expect(druid).to respond_to(:heading6)
|
|
1017
|
+
expect(druid).to respond_to(:heading6_element)
|
|
1018
|
+
end
|
|
1019
|
+
|
|
1020
|
+
it "should call a block on the element method present" do
|
|
1021
|
+
expect(block_druid.heading6_element).to eql "h6"
|
|
1022
|
+
end
|
|
1023
|
+
end
|
|
1024
|
+
|
|
1025
|
+
context "implementation" do
|
|
1026
|
+
it "should retrieve the text from the h6" do
|
|
1027
|
+
expect(driver).to receive(:h6).and_return(driver)
|
|
1028
|
+
expect(driver).to receive(:text).and_return("value")
|
|
1029
|
+
expect(druid.heading6).to eql "value"
|
|
1030
|
+
end
|
|
1031
|
+
|
|
1032
|
+
it "should retrieve the element from the page" do
|
|
1033
|
+
expect(driver).to receive(:h6).and_return(driver)
|
|
1034
|
+
expect(druid.heading6_element).to be_instance_of Druid::Elements::Heading
|
|
1035
|
+
end
|
|
1036
|
+
end
|
|
1037
|
+
end
|
|
1038
|
+
|
|
1039
|
+
describe "paragraph accessors" do
|
|
1040
|
+
context "when called on a page object" do
|
|
1041
|
+
it "should generate accessor methods" do
|
|
1042
|
+
expect(druid).to respond_to(:first_para)
|
|
1043
|
+
expect(druid).to respond_to(:first_para_element)
|
|
1044
|
+
end
|
|
1045
|
+
|
|
1046
|
+
it "should call a block on the element method when present" do
|
|
1047
|
+
expect(block_druid.first_para_element).to eql "p"
|
|
1048
|
+
end
|
|
1049
|
+
end
|
|
1050
|
+
|
|
1051
|
+
context "implementation" do
|
|
1052
|
+
it "should retrieve the text from the p" do
|
|
1053
|
+
expect(driver).to receive(:p).and_return(driver)
|
|
1054
|
+
expect(driver).to receive(:text).and_return("value")
|
|
1055
|
+
expect(druid.first_para).to eql "value"
|
|
1056
|
+
end
|
|
1057
|
+
|
|
1058
|
+
it "should retrieve the element from the page" do
|
|
1059
|
+
expect(driver).to receive(:p).and_return(driver)
|
|
1060
|
+
expect(druid.first_para_element).to be_instance_of Druid::Elements::Paragraph
|
|
1061
|
+
end
|
|
1062
|
+
end
|
|
1063
|
+
end
|
|
1064
|
+
|
|
1065
|
+
describe "file_field accessors" do
|
|
1066
|
+
context "when called on a page object" do
|
|
1067
|
+
it "should geneate accessor methods" do
|
|
1068
|
+
expect(druid).to respond_to(:upload_me=)
|
|
1069
|
+
expect(druid).to respond_to(:upload_me_element)
|
|
1070
|
+
end
|
|
1071
|
+
|
|
1072
|
+
it "should call a block on the element method when present" do
|
|
1073
|
+
expect(block_druid.a_file_element).to eql "file_field"
|
|
1074
|
+
end
|
|
1075
|
+
end
|
|
1076
|
+
|
|
1077
|
+
context "implementation" do
|
|
1078
|
+
it "should set the file name" do
|
|
1079
|
+
expect(driver).to receive(:file_field).and_return(driver)
|
|
1080
|
+
expect(driver).to receive(:set).with('some_file')
|
|
1081
|
+
druid.upload_me = 'some_file'
|
|
1082
|
+
end
|
|
1083
|
+
|
|
1084
|
+
it "should retrieve a file field element" do
|
|
1085
|
+
expect(driver).to receive(:file_field).and_return(driver)
|
|
1086
|
+
expect(druid.upload_me_element).to be_instance_of Druid::Elements::FileField
|
|
1087
|
+
end
|
|
1088
|
+
end
|
|
1089
|
+
end
|
|
1090
|
+
|
|
1091
|
+
describe "area accessors" do
|
|
1092
|
+
context "when called on a page object" do
|
|
1093
|
+
it "should generate accessor methods" do
|
|
1094
|
+
expect(druid).to respond_to(:img_area)
|
|
1095
|
+
expect(druid).to respond_to(:img_area_element)
|
|
1096
|
+
end
|
|
1097
|
+
|
|
1098
|
+
it "should call a block on the element method when present" do
|
|
1099
|
+
expect(block_druid.img_area_element).to eql "area"
|
|
1100
|
+
end
|
|
1101
|
+
end
|
|
1102
|
+
|
|
1103
|
+
it "should click on the area" do
|
|
1104
|
+
expect(driver).to receive(:area).and_return(driver)
|
|
1105
|
+
expect(driver).to receive(:click)
|
|
1106
|
+
druid.img_area
|
|
1107
|
+
end
|
|
1108
|
+
|
|
1109
|
+
it "should retrieve the element from the page" do
|
|
1110
|
+
expect(driver).to receive(:area).and_return(driver)
|
|
1111
|
+
element = druid.img_area_element
|
|
1112
|
+
expect(element).to be_instance_of Druid::Elements::Area
|
|
1113
|
+
end
|
|
1114
|
+
end
|
|
1115
|
+
|
|
1116
|
+
describe "canvas accessors" do
|
|
1117
|
+
context "when called on a page object" do
|
|
1118
|
+
it "should generate accessor methods" do
|
|
1119
|
+
expect(druid).to respond_to(:my_canvas_element)
|
|
1120
|
+
end
|
|
1121
|
+
|
|
1122
|
+
it "should call a block on the element method when present" do
|
|
1123
|
+
expect(block_druid.my_canvas_element).to eql "canvas"
|
|
1124
|
+
end
|
|
1125
|
+
end
|
|
1126
|
+
end
|
|
1127
|
+
|
|
1128
|
+
describe "audio accessors" do
|
|
1129
|
+
context "when called on a page object" do
|
|
1130
|
+
it "should generate accessor methods" do
|
|
1131
|
+
expect(druid).to respond_to(:acdc_element)
|
|
1132
|
+
end
|
|
1133
|
+
|
|
1134
|
+
it "should call a block on the element method when present" do
|
|
1135
|
+
expect(block_druid.acdc_element).to eql "audio"
|
|
1136
|
+
end
|
|
1137
|
+
end
|
|
1138
|
+
end
|
|
1139
|
+
|
|
1140
|
+
describe "video accessors" do
|
|
1141
|
+
context "when called on a page object" do
|
|
1142
|
+
it "should generate accessor methods" do
|
|
1143
|
+
expect(druid).to respond_to(:movie_element)
|
|
1144
|
+
end
|
|
1145
|
+
|
|
1146
|
+
it "should call a block on the element method when present" do
|
|
1147
|
+
expect(block_druid.movie_element).to eql "video"
|
|
1148
|
+
end
|
|
1149
|
+
end
|
|
1150
|
+
end
|
|
1151
|
+
|
|
1152
|
+
describe "b accessors" do
|
|
1153
|
+
context "when called on a page object" do
|
|
1154
|
+
it "should generate accessor methods" do
|
|
1155
|
+
expect(druid).to respond_to(:bold)
|
|
1156
|
+
expect(druid).to respond_to(:bold_element)
|
|
1157
|
+
expect(druid).to respond_to(:bold?)
|
|
1158
|
+
end
|
|
1159
|
+
|
|
1160
|
+
it "should call a block on the element method when present" do
|
|
1161
|
+
expect(block_druid.bold_element).to eql "b"
|
|
1162
|
+
end
|
|
1163
|
+
end
|
|
1164
|
+
|
|
1165
|
+
it "should retrieve the text from the b" do
|
|
1166
|
+
expect(driver).to receive(:b).and_return(driver)
|
|
1167
|
+
expect(driver).to receive(:text).and_return("value")
|
|
1168
|
+
expect(druid.bold).to eql "value"
|
|
1169
|
+
end
|
|
1170
|
+
|
|
1171
|
+
it "should retrieve the element from the page" do
|
|
1172
|
+
expect(driver).to receive(:b).and_return(driver)
|
|
1173
|
+
element = druid.bold_element
|
|
1174
|
+
expect(element).to be_instance_of Druid::Elements::Bold
|
|
1175
|
+
end
|
|
1176
|
+
end
|
|
1177
|
+
end
|
|
1178
|
+
|
|
1179
|
+
describe "accessors" do
|
|
1180
|
+
let(:driver) { mock_driver }
|
|
1181
|
+
let(:page) { GenericPage.new driver}
|
|
1182
|
+
|
|
1183
|
+
context '#wait_for_expected_title' do
|
|
1184
|
+
before(:each) do
|
|
1185
|
+
allow(driver).to receive(:wait_until).and_yield
|
|
1186
|
+
end
|
|
1187
|
+
|
|
1188
|
+
it "true if already there" do
|
|
1189
|
+
allow(driver).to receive(:title).and_return 'expected title'
|
|
1190
|
+
expect(page.wait_for_expected_title?).to be_truthy
|
|
1191
|
+
end
|
|
1192
|
+
|
|
1193
|
+
it "does not wait if it already is there" do
|
|
1194
|
+
allow(driver).to receive(:title).and_return 'expected title'
|
|
1195
|
+
expect(driver).to_not receive(:wait_until)
|
|
1196
|
+
expect(page.wait_for_expected_title?).to be_truthy
|
|
1197
|
+
end
|
|
1198
|
+
|
|
1199
|
+
it "errors when it does not match" do
|
|
1200
|
+
allow(driver).to receive(:title).and_return 'wrong title'
|
|
1201
|
+
expect { page.wait_for_expected_title? }.to raise_error "Expected title 'expected title' instead of 'wrong title'"
|
|
1202
|
+
end
|
|
1203
|
+
|
|
1204
|
+
it 'pick up when the title changes' do
|
|
1205
|
+
allow(driver).to receive(:title).and_return 'wrong title', 'expected title'
|
|
1206
|
+
expect(page.wait_for_expected_title?).to be_truthy
|
|
1207
|
+
end
|
|
1208
|
+
end
|
|
1209
|
+
end
|