druid-ts 1.1.6 → 1.1.7
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 +4 -4
- data/ChangeLog +68 -1
- data/Gemfile +1 -0
- data/cucumber.yml +1 -1
- data/features/audio.feature +33 -33
- data/features/element.feature +5 -0
- data/features/{sample-app/public → html}/04-Death_Becomes_Fur.mp4 +0 -0
- data/features/{sample-app/public → html}/04-Death_Becomes_Fur.oga +0 -0
- data/features/html/static_elements.html +2 -0
- data/features/multi_elements.feature +189 -0
- data/features/sample-app/sample_app.rb +5 -1
- data/features/step_definations/element_steps.rb +8 -0
- data/features/step_definations/form_steps.rb +2 -2
- data/features/step_definations/javasript_steps.rb +8 -2
- data/features/step_definations/multi_elements_steps.rb +118 -0
- data/features/support/persistent_browser.rb +44 -2
- data/features/support/targets/firefox14_osx.rb +5 -0
- data/features/support/targets/firefox14_windows7.rb +5 -0
- data/features/support/url_helper.rb +3 -1
- data/features/video.feature +51 -51
- data/lib/druid/accessors.rb +160 -287
- data/lib/druid/assist.rb +2 -2
- data/lib/druid/element_locators.rb +9 -1032
- data/lib/druid/elements/element.rb +7 -0
- data/lib/druid/locator_generator.rb +73 -0
- data/lib/druid/nested_elements.rb +50 -233
- data/lib/druid/page_factory.rb +7 -4
- data/lib/druid/version.rb +1 -1
- data/spec/druid/accessors_spec.rb +13 -2
- data/spec/druid/element_locators_spec.rb +5 -5
- data/spec/druid/elements/element_spec.rb +6 -0
- data/spec/druid/page_factory_spec.rb +10 -1
- metadata +10 -5
@@ -160,6 +160,13 @@ module Druid
|
|
160
160
|
attribute(:id)
|
161
161
|
end
|
162
162
|
|
163
|
+
#
|
164
|
+
# Scroll until the element is viewable
|
165
|
+
#
|
166
|
+
def scroll_into_view
|
167
|
+
element.wd.location_once_scrolled_into_view
|
168
|
+
end
|
169
|
+
|
163
170
|
#
|
164
171
|
# Flash the element by temporarily changing the background color
|
165
172
|
#
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Druid
|
2
|
+
module LocatorGenerator
|
3
|
+
|
4
|
+
def self.generate_locators(target)
|
5
|
+
[:text_field,
|
6
|
+
:hidden_field,
|
7
|
+
:text_area,
|
8
|
+
:select_list,
|
9
|
+
:link,
|
10
|
+
:checkbox,
|
11
|
+
:radio_button,
|
12
|
+
:button,
|
13
|
+
:div,
|
14
|
+
:span,
|
15
|
+
:table,
|
16
|
+
:cell,
|
17
|
+
:image,
|
18
|
+
:form,
|
19
|
+
:list_item,
|
20
|
+
:unordered_list,
|
21
|
+
:ordered_list,
|
22
|
+
:h1,
|
23
|
+
:h2,
|
24
|
+
:h3,
|
25
|
+
:h4,
|
26
|
+
:h5,
|
27
|
+
:h6,
|
28
|
+
:paragraph,
|
29
|
+
:label,
|
30
|
+
:file_field,
|
31
|
+
:area,
|
32
|
+
:canvas,
|
33
|
+
:audio,
|
34
|
+
:video,
|
35
|
+
:abbr,
|
36
|
+
:address,
|
37
|
+
:article,
|
38
|
+
:aside,
|
39
|
+
:bdi,
|
40
|
+
:cite,
|
41
|
+
:code,
|
42
|
+
:dd,
|
43
|
+
:em,
|
44
|
+
:figcaption,
|
45
|
+
:figure,
|
46
|
+
:footer,
|
47
|
+
:header,
|
48
|
+
:hgroup,
|
49
|
+
:kbd,
|
50
|
+
:mark,
|
51
|
+
:nav,
|
52
|
+
:noscript,
|
53
|
+
:rp,
|
54
|
+
:rt,
|
55
|
+
:ruby,
|
56
|
+
:samp,
|
57
|
+
:section,
|
58
|
+
:sub,
|
59
|
+
:summary,
|
60
|
+
:sup,
|
61
|
+
:var,
|
62
|
+
:wbr].each do |tag|
|
63
|
+
target.send(:define_method, "#{tag.to_s}_element") do |*identifier|
|
64
|
+
self.send "#{tag.to_s}_for", locator(identifier).clone
|
65
|
+
end
|
66
|
+
|
67
|
+
target.send(:define_method, "#{tag.to_s}_elements") do |*identifier|
|
68
|
+
self.send "#{tag.to_s}s_for", identifier[0] ? identifier[0].clone : {}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -1,239 +1,56 @@
|
|
1
|
+
require 'druid/locator_generator'
|
2
|
+
|
1
3
|
module Druid
|
2
4
|
module NestedElements
|
3
|
-
def link_element(identifier={:index => 0})
|
4
|
-
link_for(identifier)
|
5
|
-
end
|
6
|
-
|
7
|
-
def link_elements(identifier={:index => 0})
|
8
|
-
links_for(identifier)
|
9
|
-
end
|
10
|
-
|
11
|
-
def button_element(identifier={:index => 0})
|
12
|
-
button_for(identifier)
|
13
|
-
end
|
14
|
-
|
15
|
-
def button_elements(identifier={:index => 0})
|
16
|
-
buttons_for(identifier)
|
17
|
-
end
|
18
|
-
|
19
|
-
def text_field_element(identifier={:index => 0})
|
20
|
-
text_field_for(identifier)
|
21
|
-
end
|
22
|
-
|
23
|
-
def text_field_elements(identifier={:index => 0})
|
24
|
-
text_fields_for(identifier)
|
25
|
-
end
|
26
|
-
|
27
|
-
def hidden_field_element(identifier={:index => 0})
|
28
|
-
hidden_field_for(identifier)
|
29
|
-
end
|
30
|
-
|
31
|
-
def hidden_field_elements(identifier={:index => 0})
|
32
|
-
hidden_fields_for(identifier)
|
33
|
-
end
|
34
|
-
|
35
|
-
def text_area_element(identifier={:index => 0})
|
36
|
-
text_area_for(identifier)
|
37
|
-
end
|
38
|
-
|
39
|
-
def text_area_elements(identifier={:index => 0})
|
40
|
-
text_areas_for(identifier)
|
41
|
-
end
|
42
|
-
|
43
|
-
def select_list_element(identifier={:index => 0})
|
44
|
-
select_list_for(identifier)
|
45
|
-
end
|
46
|
-
|
47
|
-
def select_list_elements(identifier={:index => 0})
|
48
|
-
select_lists_for(identifier)
|
49
|
-
end
|
50
|
-
|
51
|
-
def checkbox_element(identifier={:index => 0})
|
52
|
-
checkbox_for(identifier)
|
53
|
-
end
|
54
|
-
|
55
|
-
def checkbox_elements(identifier={:index => 0})
|
56
|
-
checkboxes_for(identifier)
|
57
|
-
end
|
58
|
-
|
59
|
-
def radio_button_element(identifier={:index => 0})
|
60
|
-
radio_button_for(identifier)
|
61
|
-
end
|
62
|
-
|
63
|
-
def radio_button_elements(identifier={:index => 0})
|
64
|
-
radio_buttons_for(identifier)
|
65
|
-
end
|
66
|
-
|
67
|
-
def div_element(identifier={:index => 0})
|
68
|
-
div_for(identifier)
|
69
|
-
end
|
70
|
-
|
71
|
-
def div_elements(identifier={:index => 0})
|
72
|
-
divs_for(identifier)
|
73
|
-
end
|
74
|
-
|
75
|
-
def span_element(identifier={:index => 0})
|
76
|
-
span_for(identifier)
|
77
|
-
end
|
78
|
-
|
79
|
-
def span_elements(identifier={:index => 0})
|
80
|
-
spans_for(identifier)
|
81
|
-
end
|
82
|
-
|
83
|
-
def table_element(identifier={:index => 0})
|
84
|
-
table_for(identifier)
|
85
|
-
end
|
86
|
-
|
87
|
-
def table_elements(identifier={:index => 0})
|
88
|
-
tables_for(identifier)
|
89
|
-
end
|
90
|
-
|
91
|
-
def cell_element(identifier={:index => 0})
|
92
|
-
cell_for(identifier)
|
93
|
-
end
|
94
|
-
|
95
|
-
def cell_elements(identifier={:index => 0})
|
96
|
-
cells_for(identifier)
|
97
|
-
end
|
98
|
-
|
99
|
-
def image_element(identifier={:index => 0})
|
100
|
-
image_for(identifier)
|
101
|
-
end
|
102
|
-
|
103
|
-
def image_elements(identifier={:index => 0})
|
104
|
-
images_for(identifier)
|
105
|
-
end
|
106
|
-
|
107
|
-
def form_element(identifier={:index => 0})
|
108
|
-
form_for(identifier)
|
109
|
-
end
|
110
|
-
|
111
|
-
def form_elements(identifier={:index => 0})
|
112
|
-
forms_for(identifier)
|
113
|
-
end
|
114
|
-
|
115
|
-
def ordered_list_element(identifier={:index => 0})
|
116
|
-
ordered_list_for(identifier)
|
117
|
-
end
|
118
5
|
|
119
|
-
def
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
def h4_elements(identifier={:index => 0})
|
168
|
-
h4s_for(identifier)
|
169
|
-
end
|
170
|
-
|
171
|
-
def h5_element(identifier={:index => 0})
|
172
|
-
h5_for(identifier)
|
173
|
-
end
|
174
|
-
|
175
|
-
def h5_elements(identifier={:index => 0})
|
176
|
-
h5s_for(identifier)
|
177
|
-
end
|
6
|
+
def self.included(cls)
|
7
|
+
Druid::LocatorGenerator.generate_locators(cls)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def locator(identifier)
|
13
|
+
identifier[0] ? identifier[0] : {:index => 0}
|
14
|
+
end
|
15
|
+
|
16
|
+
# [:text_field,
|
17
|
+
# :hidden_field,
|
18
|
+
# :text_area,
|
19
|
+
# :select_list,
|
20
|
+
# :link,
|
21
|
+
# :checkbox,
|
22
|
+
# :radio_button,
|
23
|
+
# :button,
|
24
|
+
# :div,
|
25
|
+
# :span,
|
26
|
+
# :table,
|
27
|
+
# :cell,
|
28
|
+
# :image,
|
29
|
+
# :form,
|
30
|
+
# :list_item,
|
31
|
+
# :unordered_list,
|
32
|
+
# :ordered_list,
|
33
|
+
# :h1,
|
34
|
+
# :h2,
|
35
|
+
# :h3,
|
36
|
+
# :h4,
|
37
|
+
# :h5,
|
38
|
+
# :h6,
|
39
|
+
# :paragraph,
|
40
|
+
# :label,
|
41
|
+
# :file_field,
|
42
|
+
# :area,
|
43
|
+
# :canvas,
|
44
|
+
# :audio,
|
45
|
+
# :video].each do |tag|
|
46
|
+
# define_method("#{tag.to_s}_element") do |*identifier|
|
47
|
+
# self.send "#{tag.to_s}_for", locator(identifier)
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# define_method("#{tag.to_s}_elements") do |*identifier|
|
51
|
+
# self.send "#{tag.to_s}s_for", locator(identifier)
|
52
|
+
# end
|
53
|
+
# end
|
178
54
|
|
179
|
-
def h6_element(identifier={:index => 0})
|
180
|
-
h6_for(identifier)
|
181
|
-
end
|
182
|
-
|
183
|
-
def h6_elements(identifier={:index => 0})
|
184
|
-
h6s_for(identifier)
|
185
|
-
end
|
186
|
-
|
187
|
-
def paragraph_element(identifier={:index => 0})
|
188
|
-
paragraph_for(identifier)
|
189
|
-
end
|
190
|
-
|
191
|
-
def paragraph_elements(identifier={:index => 0})
|
192
|
-
paragraphs_for(identifier)
|
193
|
-
end
|
194
|
-
|
195
|
-
def file_field_element(identifier={:index => 0})
|
196
|
-
file_field_for(identifier)
|
197
|
-
end
|
198
|
-
|
199
|
-
def label_element(identifier={:index => 0})
|
200
|
-
label_for(identifier)
|
201
|
-
end
|
202
|
-
|
203
|
-
def label_elements(identifier={:index => 0})
|
204
|
-
labels_for(identifier)
|
205
|
-
end
|
206
|
-
|
207
|
-
def area_element(identifier={:index => 0})
|
208
|
-
area_for(identifier)
|
209
|
-
end
|
210
|
-
|
211
|
-
def area_elements(identifier={:index => 0})
|
212
|
-
areas_for(identifier)
|
213
|
-
end
|
214
|
-
|
215
|
-
def canvas_element(identifier={:index => 0})
|
216
|
-
canvas_for(identifier)
|
217
|
-
end
|
218
|
-
|
219
|
-
def canvas_elements(identifier={:index => 0})
|
220
|
-
canvases_for(identifier)
|
221
|
-
end
|
222
|
-
|
223
|
-
def audio_element(identifier={:index => 0})
|
224
|
-
audio_for(identifier)
|
225
|
-
end
|
226
|
-
|
227
|
-
def audio_elements(identifier={:index => 0})
|
228
|
-
audios_for(identifier)
|
229
|
-
end
|
230
|
-
|
231
|
-
def video_element(identifier={:index => 0})
|
232
|
-
video_for(identifier)
|
233
|
-
end
|
234
|
-
|
235
|
-
def video_elements(identifier={:index => 0})
|
236
|
-
videos_for(identifier)
|
237
|
-
end
|
238
55
|
end
|
239
56
|
end
|
data/lib/druid/page_factory.rb
CHANGED
@@ -25,8 +25,10 @@ module Druid
|
|
25
25
|
# @example Example routes defined in env.rb
|
26
26
|
# Druid::PageFactory.routes = {
|
27
27
|
# :default => [[PageOne,:method1], [PageTwoA,:method2], [PageThree,:method3],
|
28
|
-
# :another_route => [[PageOne,:method1], [PageTwoB,:method2b], [PageThree,:method3]]
|
28
|
+
# :another_route => [[PageOne,:method1,"arg1"], [PageTwoB,:method2b], [PageThree,:method3]]
|
29
29
|
# }
|
30
|
+
# Notice the first entry of :another_route is passing an argument
|
31
|
+
# to the method
|
30
32
|
# You must also call the navigation_method on each page.
|
31
33
|
module PageFactory
|
32
34
|
# attr_accessor :page
|
@@ -154,10 +156,11 @@ module Druid
|
|
154
156
|
end
|
155
157
|
|
156
158
|
def navigate_through_pages(pages)
|
157
|
-
pages.each do |cls, method|
|
159
|
+
pages.each do |cls, method, *args|
|
158
160
|
page = on_page(cls)
|
159
|
-
fail("Navigation method not specified on #{cls}.
|
160
|
-
page.send method
|
161
|
+
fail("Navigation method not specified on #{cls}.") unless page.respond_to? method
|
162
|
+
page.send method unless args
|
163
|
+
page.send method, *args if args
|
161
164
|
end
|
162
165
|
end
|
163
166
|
|
data/lib/druid/version.rb
CHANGED
@@ -190,7 +190,7 @@ describe Druid::Accessors do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
it "should raise error when it does not have expected title" do
|
193
|
-
expect(driver).to receive(:title).
|
193
|
+
expect(driver).to receive(:title).and_return("Not Expected")
|
194
194
|
expect {druid.has_expected_title? }.to raise_error
|
195
195
|
end
|
196
196
|
end
|
@@ -484,6 +484,17 @@ describe Druid::Accessors do
|
|
484
484
|
expect(driver).to receive(:select_list)
|
485
485
|
expect(druid.state_element).to be_instance_of Druid::Elements::SelectList
|
486
486
|
end
|
487
|
+
|
488
|
+
it "should return list of selection options" do
|
489
|
+
option1 = double('option')
|
490
|
+
option2 = double('option')
|
491
|
+
expect(option1).to receive(:text).and_return("CA")
|
492
|
+
expect(option2).to receive(:text).and_return('OH')
|
493
|
+
select_element = double("select")
|
494
|
+
expect(select_element).to receive(:options).twice.and_return([option1,option2])
|
495
|
+
expect(druid).to receive(:state_element).and_return(select_element)
|
496
|
+
expect(druid.state_options).to eql ["CA","OH"]
|
497
|
+
end
|
487
498
|
end
|
488
499
|
end
|
489
500
|
|
@@ -634,7 +645,7 @@ describe Druid::Accessors do
|
|
634
645
|
end
|
635
646
|
|
636
647
|
it "should call a block on the element method when present" do
|
637
|
-
expect(block_druid.
|
648
|
+
expect(block_druid.total_element).to eql "cell"
|
638
649
|
end
|
639
650
|
end
|
640
651
|
|
@@ -582,15 +582,15 @@ describe Druid::ElementLocators do
|
|
582
582
|
page.label_elements
|
583
583
|
end
|
584
584
|
|
585
|
-
it "should find an element" do
|
585
|
+
it "should find an audio element" do
|
586
586
|
expect(driver).to receive(:audio).with(:id => 'blah').and_return(driver)
|
587
|
-
element = page.
|
588
|
-
expect(element).to be_instance_of Druid::Elements::
|
587
|
+
element = page.audio_element(:id => 'blah')
|
588
|
+
expect(element).to be_instance_of Druid::Elements::Audio
|
589
589
|
end
|
590
590
|
|
591
|
-
it "should find an element using a default identifier" do
|
591
|
+
it "should find an audio element using a default identifier" do
|
592
592
|
expect(driver).to receive(:audio).with(:index => 0).and_return(driver)
|
593
|
-
page.
|
593
|
+
page.audio_element
|
594
594
|
end
|
595
595
|
|
596
596
|
it "should find an area element" do
|