druid-ts 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +21 -2
- data/Gemfile +1 -1
- data/druid.gemspec +3 -3
- data/features/element.feature +0 -5
- data/features/frames.feature +4 -0
- data/features/html/static_elements.html +11 -0
- data/features/populate_page_with.feature +25 -0
- data/features/select_list.feature +1 -0
- data/features/step_definations/audio_steps.rb +1 -1
- data/features/step_definations/element_steps.rb +0 -4
- data/features/step_definations/frame_steps.rb +35 -0
- data/features/step_definations/populate_page_with_steps.rb +3 -0
- data/features/step_definations/select_list_steps.rb +4 -0
- data/features/step_definations/table_steps.rb +19 -0
- data/features/support/page.rb +2 -0
- data/features/table.feature +21 -0
- data/lib/druid.rb +0 -1
- data/lib/druid/assist.rb +8 -5
- data/lib/druid/elements/area.rb +0 -20
- data/lib/druid/elements/check_box.rb +0 -20
- data/lib/druid/elements/element.rb +73 -64
- data/lib/druid/elements/file_field.rb +0 -6
- data/lib/druid/elements/hidden_field.rb +0 -4
- data/lib/druid/elements/image.rb +0 -7
- data/lib/druid/elements/media.rb +0 -34
- data/lib/druid/elements/ordered_list.rb +8 -21
- data/lib/druid/elements/radio_button.rb +0 -13
- data/lib/druid/elements/select_list.rb +2 -11
- data/lib/druid/elements/table.rb +41 -16
- data/lib/druid/elements/table_row.rb +21 -17
- data/lib/druid/elements/text_area.rb +0 -7
- data/lib/druid/elements/text_field.rb +0 -7
- data/lib/druid/elements/unordered_list.rb +9 -22
- data/lib/druid/javascript_framework_facade.rb +1 -1
- data/lib/druid/locator_generator.rb +153 -147
- data/lib/druid/page_populator.rb +44 -37
- data/lib/druid/version.rb +1 -1
- data/spec/druid/accessors_spec.rb +3 -3
- data/spec/druid/elements/check_box_spec.rb +0 -15
- data/spec/druid/elements/element_spec.rb +77 -78
- data/spec/druid/elements/file_field_spec.rb +0 -5
- data/spec/druid/elements/media_spec.rb +0 -49
- data/spec/druid/elements/ordered_list_spec.rb +24 -20
- data/spec/druid/elements/radio_button_spec.rb +0 -10
- data/spec/druid/elements/table_row_spec.rb +12 -12
- data/spec/druid/elements/table_spec.rb +29 -25
- data/spec/druid/elements/text_area_spec.rb +0 -4
- data/spec/druid/elements/text_field_spec.rb +0 -5
- data/spec/druid/elements/unordered_list_spec.rb +25 -20
- data/spec/druid/javascript_framework_facade_spec.rb +1 -1
- data/spec/druid/page_populator_spec.rb +34 -4
- metadata +15 -18
- data/lib/druid/core_ext/string.rb +0 -5
- data/spec/druid/elements/area_spec.rb +0 -25
- data/spec/druid/elements/canvas_spec.rb +0 -19
- data/spec/druid/elements/video_spec.rb +0 -25
data/lib/druid/page_populator.rb
CHANGED
@@ -23,74 +23,81 @@ module Druid
|
|
23
23
|
# example_page = ExamplePage.new(@browser)
|
24
24
|
# example_page.populate_page_with :username => 'a name', :active => true
|
25
25
|
#
|
26
|
-
# @param [Hash] the data to use to populate this page. The key
|
26
|
+
# @param data [Hash] the data to use to populate this page. The key
|
27
27
|
# can be either a string or a symbol. The value must be a string
|
28
28
|
# for TextField, TextArea, SelectList and FileField must be true or
|
29
29
|
# false for a Checkbox or RadioButton.
|
30
30
|
#
|
31
31
|
def populate_page_with(data)
|
32
32
|
data.each do |key, value|
|
33
|
-
|
34
|
-
|
35
|
-
populate_radiobutton(key, value) if is_radiobutton?(key) and is_enabled?(key)
|
36
|
-
populate_select_list(key, value) if is_select_list?(key)
|
37
|
-
populate_text(key, value) if is_text?(key) and is_enabled?(key)
|
33
|
+
populate_section(key, value) if value.is_a?(Hash)
|
34
|
+
populate_value(self, key, value)
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
41
38
|
private
|
42
39
|
|
43
|
-
def
|
44
|
-
self.
|
40
|
+
def populate_section(section, data)
|
41
|
+
return unless self.respond_to? section
|
42
|
+
data.each do |key, value|
|
43
|
+
populate_value(self.send(section), key, value)
|
44
|
+
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
47
|
+
def populate_value(receiver, key, value)
|
48
|
+
populate_checkbox(receiver, key, value) if is_checkbox?(receiver, key) and is_enabled?(receiver, key)
|
49
|
+
populate_radiobuttongroup(receiver, key, value) if is_radiobuttongroup?(receiver, key)
|
50
|
+
populate_radiobutton(receiver, key, value) if is_radiobutton?(receiver, key) and is_enabled?(receiver, key)
|
51
|
+
populate_select_list(receiver, key, value) if is_select_list?(receiver, key)
|
52
|
+
populate_text(receiver, key, value) if is_text?(receiver, key) and is_enabled?(receiver, key)
|
50
53
|
end
|
51
54
|
|
52
|
-
def
|
53
|
-
|
55
|
+
def populate_text(receiver, key, value)
|
56
|
+
receiver.send "#{key}=", value
|
54
57
|
end
|
55
58
|
|
56
|
-
def
|
57
|
-
return
|
59
|
+
def populate_checkbox(receiver, key, value)
|
60
|
+
return receiver.send "check_#{key}" if value
|
61
|
+
return receiver.send "uncheck_#{key}"
|
58
62
|
end
|
59
63
|
|
60
|
-
def
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
def populate_radiobutton(receiver, key, value)
|
65
|
+
return receiver.send "select_#{key}" if value
|
66
|
+
end
|
67
|
+
|
68
|
+
def populate_radiobuttongroup(receiver, key, value)
|
69
|
+
return receiver.send "select_#{key}", value
|
70
|
+
end
|
71
|
+
|
72
|
+
def populate_select_list(receiver, key, value)
|
73
|
+
receiver.send "#{key}=", value
|
67
74
|
end
|
68
75
|
|
69
|
-
def is_text?(key)
|
70
|
-
return false if is_select_list?(key)
|
71
|
-
respond_to?("#{key}=".to_sym)
|
76
|
+
def is_text?(receiver, key)
|
77
|
+
return false if is_select_list?(receiver, key)
|
78
|
+
receiver.respond_to?("#{key}=".to_sym)
|
72
79
|
end
|
73
80
|
|
74
|
-
def is_checkbox?(key)
|
75
|
-
respond_to?("check_#{key}".to_sym)
|
81
|
+
def is_checkbox?(receiver, key)
|
82
|
+
receiver.respond_to?("check_#{key}".to_sym)
|
76
83
|
end
|
77
84
|
|
78
|
-
def is_radiobutton?(key)
|
79
|
-
respond_to?("select_#{key}".to_sym)
|
85
|
+
def is_radiobutton?(receiver, key)
|
86
|
+
receiver.respond_to?("select_#{key}".to_sym)
|
80
87
|
end
|
81
88
|
|
82
|
-
def is_radiobuttongroup?(key)
|
83
|
-
respond_to?("select_#{key}".to_sym) and respond_to?("#{key}_values")
|
89
|
+
def is_radiobuttongroup?(receiver, key)
|
90
|
+
receiver.respond_to?("select_#{key}".to_sym) and receiver.respond_to?("#{key}_values")
|
84
91
|
end
|
85
92
|
|
86
|
-
def is_select_list?(key)
|
87
|
-
respond_to?("#{key}_options".to_sym)
|
93
|
+
def is_select_list?(receiver, key)
|
94
|
+
receiver.respond_to?("#{key}_options".to_sym)
|
88
95
|
end
|
89
96
|
|
90
|
-
def is_enabled?(key)
|
91
|
-
return false if is_radiobuttongroup?(key)
|
92
|
-
return true if (
|
93
|
-
element =
|
97
|
+
def is_enabled?(receiver, key)
|
98
|
+
return false if is_radiobuttongroup?(receiver, key)
|
99
|
+
return true if (receiver.send "#{key}_element").tag_name == "textarea"
|
100
|
+
element = receiver.send("#{key}_element")
|
94
101
|
element.enabled? and element.visible?
|
95
102
|
end
|
96
103
|
end
|
data/lib/druid/version.rb
CHANGED
@@ -509,9 +509,9 @@ describe Druid::Accessors do
|
|
509
509
|
|
510
510
|
context "implementation" do
|
511
511
|
it "should get the current item from a select list" do
|
512
|
-
|
513
|
-
|
514
|
-
expect(driver).to
|
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
515
|
expect(druid.state).to eql 'OH'
|
516
516
|
end
|
517
517
|
|
@@ -6,21 +6,6 @@ describe Druid::Elements::CheckBox do
|
|
6
6
|
let(:element) { double 'element' }
|
7
7
|
let(:checkbox) { Druid::Elements::CheckBox.new(element) }
|
8
8
|
|
9
|
-
it "should check" do
|
10
|
-
expect(element).to receive(:set)
|
11
|
-
checkbox.check
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should uncheck" do
|
15
|
-
expect(element).to receive(:clear)
|
16
|
-
checkbox.uncheck
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should know if it is checked" do
|
20
|
-
expect(element).to receive(:set?)
|
21
|
-
checkbox.checked?
|
22
|
-
end
|
23
|
-
|
24
9
|
it "should register with type :checkbox" do
|
25
10
|
expect(Druid::Elements.element_class_for(:input, :checkbox)).to be Druid::Elements::CheckBox
|
26
11
|
end
|
@@ -56,52 +56,57 @@ describe Druid::Elements::Element do
|
|
56
56
|
expect(element.value).to eql 'value'
|
57
57
|
end
|
58
58
|
|
59
|
-
it "should know how to retrieve the value of an attribute" do
|
60
|
-
expect(we).to receive(:attribute_value).with('class').and_return('tim')
|
61
|
-
expect(element.attribute('class')).to eql 'tim'
|
62
|
-
end
|
63
|
-
|
64
59
|
it "should be clickable" do
|
65
60
|
expect(we).to receive(:click)
|
66
61
|
element.click
|
67
62
|
end
|
68
63
|
|
64
|
+
it "should check if the element is visible" do
|
65
|
+
expect(we).to receive(:visible?).and_return(false)
|
66
|
+
expect(we).to receive(:visible?).and_return(true)
|
67
|
+
expect(element.check_visible).to be true
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should check if the element exists" do
|
71
|
+
expect(we).to receive(:exists?).and_return(false)
|
72
|
+
expect(we).to receive(:exists?).and_return(true)
|
73
|
+
expect(element.check_exist).to be true
|
74
|
+
end
|
75
|
+
|
69
76
|
it "should be able to block until it is present" do
|
70
|
-
|
77
|
+
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
|
71
78
|
element.when_present(10)
|
72
79
|
end
|
73
80
|
|
74
81
|
it "should return the element when it is present" do
|
75
|
-
|
76
|
-
|
82
|
+
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
|
83
|
+
new_element = element.when_present(10)
|
84
|
+
expect(new_element).to eql element
|
77
85
|
end
|
78
86
|
|
79
87
|
it "should use the overriden wait when set" do
|
80
88
|
Druid.default_element_wait = 20
|
81
|
-
|
89
|
+
allow(we).to receive(:wait_until).with(timeout: 20, message: "Element not present in 20 seconds")
|
82
90
|
element.when_present
|
83
91
|
end
|
84
92
|
|
85
93
|
it "should be able to block until it is visible" do
|
86
94
|
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
it "should return the element when it is visible" do
|
92
|
-
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
|
93
|
-
expect(we).to receive(:wait_until).with(timeout: 10, message: "Element not visible in 10 seconds")
|
94
|
-
expect(element.when_visible(10)).to eq element
|
95
|
+
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not visible in 10 seconds")
|
96
|
+
allow(we).to receive(:displayed?).and_return(true)
|
97
|
+
new_element = element.when_visible(10)
|
98
|
+
expect(new_element).to eql element
|
95
99
|
end
|
96
100
|
|
97
101
|
it "should be able to block until it is not visible" do
|
98
102
|
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
|
99
|
-
|
103
|
+
allow(we).to receive(:wait_while).with(timeout: 10, message: "Element still visible after 10 seconds")
|
104
|
+
allow(we).to receive(:displayed?).and_return(false)
|
100
105
|
element.when_not_visible(10)
|
101
106
|
end
|
102
107
|
|
103
108
|
it "should be able to block until a user define event fires true" do
|
104
|
-
|
109
|
+
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element blah")
|
105
110
|
element.wait_until(10, "Element blah") {true}
|
106
111
|
end
|
107
112
|
|
@@ -150,18 +155,6 @@ describe Druid::Elements::Element do
|
|
150
155
|
element.focus
|
151
156
|
end
|
152
157
|
|
153
|
-
it "should check if the element is visible" do
|
154
|
-
expect(we).to receive(:visible?).and_return(false)
|
155
|
-
expect(we).to receive(:visible?).and_return(true)
|
156
|
-
expect(element.check_visible).to be true
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should check if the element exists" do
|
160
|
-
expect(we).to receive(:exist?).and_return(false)
|
161
|
-
expect(we).to receive(:exist?).and_return(true)
|
162
|
-
expect(element.check_exist).to be true
|
163
|
-
end
|
164
|
-
|
165
158
|
it "should know if the element is disabled" do
|
166
159
|
expect(we).to receive(:enabled?).and_return(false)
|
167
160
|
expect(element).to be_disabled
|
@@ -172,74 +165,80 @@ describe Druid::Elements::Element do
|
|
172
165
|
element.flash
|
173
166
|
end
|
174
167
|
|
175
|
-
it "should
|
176
|
-
expect(we).to receive(:
|
177
|
-
|
178
|
-
element.scroll_into_view
|
168
|
+
it "should return the outer html" do
|
169
|
+
expect(we).to receive(:outer_html).and_return("<div>blah</div>")
|
170
|
+
element.outer_html
|
179
171
|
end
|
180
172
|
|
181
|
-
it "should
|
182
|
-
expect(we).to receive(:
|
183
|
-
|
184
|
-
element.location
|
173
|
+
it "should return the inner html" do
|
174
|
+
expect(we).to receive(:inner_html).and_return("blah")
|
175
|
+
element.inner_html
|
185
176
|
end
|
186
177
|
|
187
|
-
it "should know
|
188
|
-
expect(we).to receive(:
|
189
|
-
expect(
|
190
|
-
element.size
|
178
|
+
it "should know if it is stale" do
|
179
|
+
expect(we).to receive(:stale?).and_return(false)
|
180
|
+
expect(element.stale?).to be false
|
191
181
|
end
|
182
|
+
end
|
192
183
|
|
184
|
+
context 'walking the dom' do
|
185
|
+
let(:found) { double('found').as_null_object }
|
193
186
|
|
194
|
-
|
195
|
-
|
196
|
-
expect(we).to receive(:size).and_return({'width' => 30, 'height' => 20})
|
197
|
-
expect(element.height).to eql 20
|
187
|
+
before do
|
188
|
+
allow(found).to receive(:tag_name).and_return(:span)
|
198
189
|
end
|
199
190
|
|
200
|
-
it
|
201
|
-
expect(we).to receive(:
|
202
|
-
|
203
|
-
expect(
|
191
|
+
it 'should find the parent object' do
|
192
|
+
expect(we).to receive(:parent).and_return(found)
|
193
|
+
object = element.parent
|
194
|
+
expect(object).to be_a(Druid::Elements::Span)
|
195
|
+
expect(object.tag_name).to eql :span
|
204
196
|
end
|
205
197
|
|
206
|
-
it
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
expect(
|
211
|
-
'y' => 90,
|
212
|
-
'x' => 55
|
213
|
-
)
|
198
|
+
it 'should find the proceeding sibling' do
|
199
|
+
expect(we).to receive(:preceding_sibling).and_return(found)
|
200
|
+
object = element.preceding_sibling
|
201
|
+
expect(object).to be_a(Druid::Elements::Span)
|
202
|
+
expect(object.tag_name).to eql :span
|
214
203
|
end
|
215
204
|
|
216
|
-
it
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
expect(
|
205
|
+
it 'should find the following sibling' do
|
206
|
+
expect(we).to receive(:following_sibling).and_return(found)
|
207
|
+
object = element.following_sibling
|
208
|
+
expect(object).to be_a(Druid::Elements::Span)
|
209
|
+
expect(object.tag_name).to eql :span
|
221
210
|
end
|
222
211
|
|
223
|
-
it
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
expect(
|
212
|
+
it 'should find all of its siblings' do
|
213
|
+
expect(we).to receive(:siblings).and_return([found, found])
|
214
|
+
results = element.siblings
|
215
|
+
expect(results.size).to eql 2
|
216
|
+
expect(results[0]).to be_a(Druid::Elements::Span)
|
217
|
+
expect(results[1]).to be_a(Druid::Elements::Span)
|
228
218
|
end
|
229
219
|
|
230
|
-
it
|
231
|
-
expect(we).to receive(:
|
232
|
-
element.
|
220
|
+
it 'should find all of its children' do
|
221
|
+
expect(we).to receive(:children).and_return([found, found])
|
222
|
+
results = element.children
|
223
|
+
expect(results.size).to eql 2
|
224
|
+
expect(results[0]).to be_a(Druid::Elements::Span)
|
225
|
+
expect(results[1]).to be_a(Druid::Elements::Span)
|
233
226
|
end
|
234
227
|
|
235
|
-
it
|
236
|
-
expect(we).to receive(:
|
237
|
-
element.
|
228
|
+
it 'should find all of the preceding siblings' do
|
229
|
+
expect(we).to receive(:preceding_siblings).and_return([found, found])
|
230
|
+
results = element.preceding_siblings
|
231
|
+
expect(results.size).to eql 2
|
232
|
+
expect(results[0]).to be_a(Druid::Elements::Span)
|
233
|
+
expect(results[1]).to be_a(Druid::Elements::Span)
|
238
234
|
end
|
239
235
|
|
240
|
-
it
|
241
|
-
expect(we).to receive(:
|
242
|
-
|
236
|
+
it 'should find all of the following siblings' do
|
237
|
+
expect(we).to receive(:following_siblings).and_return([found, found])
|
238
|
+
results = element.following_siblings
|
239
|
+
expect(results.size).to eql 2
|
240
|
+
expect(results[0]).to be_a(Druid::Elements::Span)
|
241
|
+
expect(results[1]).to be_a(Druid::Elements::Span)
|
243
242
|
end
|
244
243
|
end
|
245
244
|
end
|
@@ -6,11 +6,6 @@ describe Druid::Elements::FileField do
|
|
6
6
|
let(:element) { double 'element' }
|
7
7
|
let(:file_field) { Druid::Elements::FileField.new(element) }
|
8
8
|
|
9
|
-
it "should set its' value" do
|
10
|
-
expect(element).to receive(:set).with('a file')
|
11
|
-
file_field.value = 'a file'
|
12
|
-
end
|
13
|
-
|
14
9
|
it "should register as type :file" do
|
15
10
|
expect(Druid::Elements.element_class_for(:input, :file)).to be Druid::Elements::FileField
|
16
11
|
end
|
@@ -4,58 +4,9 @@ describe Druid::Elements::Media do
|
|
4
4
|
let(:element) { double 'element' }
|
5
5
|
let(:media) { Druid::Elements::Media.new(element) }
|
6
6
|
|
7
|
-
it "should return autoplay" do
|
8
|
-
expect(media).to receive(:attribute).with(:autoplay).and_return(true)
|
9
|
-
expect(media.autoplay?).to eq(true)
|
10
|
-
end
|
11
|
-
|
12
7
|
it "should return controls" do
|
13
8
|
expect(media).to receive(:attribute).with(:controls).and_return(true)
|
14
9
|
expect(media.has_controls?).to eq(true)
|
15
10
|
end
|
16
11
|
|
17
|
-
it "should return paused" do
|
18
|
-
expect(media).to receive(:attribute).with(:paused).and_return(true)
|
19
|
-
expect(media.paused?).to eq(true)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should not return duration when not present" do
|
23
|
-
expect(media).to receive(:attribute).with(:duration).and_return(nil)
|
24
|
-
expect(media.duration).to eq(nil)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should return duration when present" do
|
28
|
-
expect(media).to receive(:attribute).with(:duration).and_return('1.405')
|
29
|
-
expect(media.duration).to eq(1.405)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should not return volume when not present" do
|
33
|
-
expect(media).to receive(:attribute).with(:volume).and_return(nil)
|
34
|
-
expect(media.volume).to eq(nil)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should return volume when present" do
|
38
|
-
expect(media).to receive(:attribute).with(:volume).and_return('3')
|
39
|
-
expect(media.volume).to eq(3)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should return ended" do
|
43
|
-
expect(media).to receive(:attribute).with(:ended).and_return(true)
|
44
|
-
expect(media.ended?).to eq(true)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should return seeking" do
|
48
|
-
expect(media).to receive(:attribute).with(:seeking).and_return(true)
|
49
|
-
expect(media.seeking?).to eq(true)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should return loop" do
|
53
|
-
expect(media).to receive(:attribute).with(:loop).and_return(true)
|
54
|
-
expect(media.loop?).to eq(true)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should return muted" do
|
58
|
-
expect(media).to receive(:attribute).with(:muted).and_return(true)
|
59
|
-
expect(media.muted?).to eq(true)
|
60
|
-
end
|
61
12
|
end
|