druid-ts 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +18 -3
- data/ChangeLog +27 -0
- data/Gemfile +9 -7
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/druid.gemspec +6 -5
- data/features/async.feature +2 -10
- data/features/audio.feature +20 -24
- data/features/element.feature +31 -0
- data/features/html/multi_elements.html +1 -0
- data/features/html/static_elements.html +5 -11
- data/features/image.feature +4 -0
- data/features/italic.feature +21 -0
- data/features/link.feature +8 -0
- data/features/multi_elements.feature +6 -0
- data/features/{html → sample-app/public}/04-Death_Becomes_Fur.mp4 +0 -0
- data/features/{html → sample-app/public}/04-Death_Becomes_Fur.oga +0 -0
- data/features/sample-app/public/audio_video.html +19 -0
- data/features/section.feature +4 -0
- data/features/select_list.feature +1 -1
- data/features/step_definations/audio_steps.rb +26 -10
- data/features/step_definations/div_steps.rb +1 -1
- data/features/step_definations/element_steps.rb +44 -0
- data/features/step_definations/image_steps.rb +8 -0
- data/features/step_definations/italic_steps.rb +11 -0
- data/features/step_definations/multi_elements_steps.rb +17 -0
- data/features/step_definations/section_steps.rb +9 -0
- data/features/step_definations/select_list_steps.rb +1 -1
- data/features/step_definations/table_row_steps.rb +23 -0
- data/features/step_definations/video_steps.rb +11 -3
- data/features/support/audio_video_page.rb +23 -0
- data/features/support/env.rb +1 -1
- data/features/support/hooks.rb +0 -4
- data/features/support/page.rb +20 -18
- data/features/support/persistent_browser.rb +3 -3
- data/features/table_row.feature +30 -0
- data/features/text_field.feature +0 -1
- data/features/video.feature +24 -7
- data/lib/druid.rb +22 -4
- data/lib/druid/accessors.rb +81 -5
- data/lib/druid/assist.rb +47 -1
- data/lib/druid/elements.rb +1 -0
- data/lib/druid/elements/canvas.rb +0 -13
- data/lib/druid/elements/element.rb +101 -26
- data/lib/druid/elements/italic.rb +9 -0
- data/lib/druid/elements/option.rb +6 -0
- data/lib/druid/elements/ordered_list.rb +7 -5
- data/lib/druid/elements/text_area.rb +14 -0
- data/lib/druid/elements/text_field.rb +1 -1
- data/lib/druid/elements/unordered_list.rb +11 -5
- data/lib/druid/elements/video.rb +0 -9
- data/lib/druid/locator_generator.rb +47 -0
- data/lib/druid/section_collection.rb +17 -0
- data/lib/druid/version.rb +1 -1
- data/spec/druid/accessors_spec.rb +29 -1
- data/spec/druid/druid_spec.rb +36 -3
- data/spec/druid/element_locators_spec.rb +44 -0
- data/spec/druid/elements/canvas_spec.rb +2 -2
- data/spec/druid/elements/element_spec.rb +98 -13
- data/spec/druid/elements/itatic_spec.rb +20 -0
- data/spec/druid/elements/media_spec.rb +61 -0
- data/spec/druid/elements/option_spec.rb +11 -0
- data/spec/druid/elements/ordered_list_spec.rb +2 -9
- data/spec/druid/elements/text_field_spec.rb +1 -1
- data/spec/druid/elements/unordered_list_spec.rb +2 -9
- data/spec/druid/elements/video_spec.rb +25 -0
- data/spec/druid/javascript_framework_facade_spec.rb +2 -2
- data/spec/druid/page_factory_spec.rb +1 -1
- data/spec/druid/page_section_spec.rb +10 -1
- data/spec/spec_helper.rb +1 -1
- metadata +49 -16
- data/lib/druid/sections.rb +0 -29
@@ -21,19 +21,21 @@ module Druid
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def list_items
|
25
|
+
children.collect do |obj|
|
26
|
+
Druid::Elements::ListItem.new(obj)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
protected
|
25
31
|
|
26
32
|
def child_xpath
|
27
|
-
"
|
33
|
+
"./child::li"
|
28
34
|
end
|
29
35
|
|
30
36
|
private
|
31
37
|
|
32
38
|
def children
|
33
|
-
list_items.find_all { |item| item.parent == element }
|
34
|
-
end
|
35
|
-
|
36
|
-
def list_items
|
37
39
|
element.ols(:xpath => child_xpath)
|
38
40
|
end
|
39
41
|
|
@@ -12,6 +12,20 @@ module Druid
|
|
12
12
|
element.set(new_value)
|
13
13
|
end
|
14
14
|
|
15
|
+
#
|
16
|
+
# Clear the TextArea
|
17
|
+
#
|
18
|
+
def clear
|
19
|
+
element.clear
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# append the text to the end of the text in the text area
|
24
|
+
#
|
25
|
+
def append(text)
|
26
|
+
element.append(text)
|
27
|
+
end
|
28
|
+
|
15
29
|
end
|
16
30
|
|
17
31
|
Druid::Elements.tag_to_class[:textarea] = Druid::Elements::TextArea
|
@@ -20,19 +20,25 @@ module Druid
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
#
|
24
|
+
# return the ListItem objects that are children of the
|
25
|
+
# UnOrderedList
|
26
|
+
#
|
27
|
+
def list_items
|
28
|
+
children.collect do |obj|
|
29
|
+
Druid::Elements::ListItem.new(obj)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
23
33
|
protected
|
24
34
|
|
25
35
|
def child_xpath
|
26
|
-
"
|
36
|
+
"./child::li"
|
27
37
|
end
|
28
38
|
|
29
39
|
private
|
30
40
|
|
31
41
|
def children
|
32
|
-
list_items.find_all { |item| item.parent == element}
|
33
|
-
end
|
34
|
-
|
35
|
-
def list_items
|
36
42
|
element.uls(:xpath => child_xpath)
|
37
43
|
end
|
38
44
|
end
|
data/lib/druid/elements/video.rb
CHANGED
@@ -2,15 +2,6 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class Video < Media
|
4
4
|
|
5
|
-
def height
|
6
|
-
height = attribute(:height)
|
7
|
-
return height.to_i if height
|
8
|
-
end
|
9
|
-
|
10
|
-
def width
|
11
|
-
width = attribute(:width)
|
12
|
-
return width.to_i if width
|
13
|
-
end
|
14
5
|
end
|
15
6
|
Druid::Elements.type_to_class[:video] = Druid::Elements::Video
|
16
7
|
end
|
@@ -3,71 +3,116 @@ module Druid
|
|
3
3
|
|
4
4
|
BASIC_ELEMENTS = [:abbr,
|
5
5
|
:address,
|
6
|
+
:animate,
|
7
|
+
:animate_motion,
|
8
|
+
:animate_transform,
|
6
9
|
:article,
|
7
10
|
:as,
|
8
11
|
:aside,
|
12
|
+
:base,
|
9
13
|
:bdi,
|
10
14
|
:bdo,
|
11
15
|
:blockquote,
|
12
16
|
:body,
|
13
17
|
:br,
|
14
18
|
:caption,
|
19
|
+
:circle,
|
15
20
|
:cite,
|
16
21
|
:code,
|
17
22
|
:col,
|
18
23
|
:colgroup,
|
19
24
|
:command,
|
25
|
+
:cursor,
|
20
26
|
:data,
|
21
27
|
:datalist,
|
22
28
|
:dd,
|
29
|
+
:defs,
|
23
30
|
:del,
|
31
|
+
:desc,
|
24
32
|
:details,
|
25
33
|
:dfn,
|
26
34
|
:dialog,
|
35
|
+
:discard,
|
27
36
|
:dl,
|
28
37
|
:dt,
|
38
|
+
:ellipse,
|
29
39
|
:em,
|
30
40
|
:embed,
|
31
41
|
:fieldset,
|
32
42
|
:figcaption,
|
33
43
|
:figure,
|
44
|
+
:foot,
|
34
45
|
:footer,
|
46
|
+
:foreign_object,
|
47
|
+
:g,
|
35
48
|
:head,
|
36
49
|
:header,
|
37
50
|
:hgroup,
|
38
51
|
:hr,
|
52
|
+
:html,
|
39
53
|
:ins,
|
40
54
|
:kbd,
|
41
55
|
:keygen,
|
42
56
|
:legend,
|
57
|
+
:line,
|
58
|
+
:linear_gradient,
|
59
|
+
:main,
|
43
60
|
:map,
|
44
61
|
:mark,
|
62
|
+
:marker,
|
45
63
|
:menu,
|
64
|
+
:menuitem,
|
65
|
+
:mesh_gradient,
|
66
|
+
:mesh_patch,
|
67
|
+
:mesh_row,
|
46
68
|
:meta,
|
69
|
+
:metadata,
|
47
70
|
:meter,
|
71
|
+
:mpath,
|
48
72
|
:nav,
|
49
73
|
:noscript,
|
50
74
|
:object,
|
51
75
|
:optgroup,
|
52
76
|
:output,
|
77
|
+
:p,
|
53
78
|
:param,
|
79
|
+
:path,
|
80
|
+
:pattern,
|
81
|
+
:polygon,
|
82
|
+
:polyline,
|
54
83
|
:pre,
|
55
84
|
:progress,
|
85
|
+
:q,
|
86
|
+
:radial_gradient,
|
87
|
+
:rect,
|
56
88
|
:rp,
|
57
89
|
:rt,
|
58
90
|
:ruby,
|
91
|
+
:s,
|
59
92
|
:samp,
|
93
|
+
:script,
|
60
94
|
:section,
|
61
95
|
:small,
|
96
|
+
:source,
|
97
|
+
:stop,
|
62
98
|
:strong,
|
63
99
|
:style,
|
64
100
|
:sub,
|
65
101
|
:summary,
|
66
102
|
:sup,
|
103
|
+
:switch,
|
104
|
+
:symbol,
|
105
|
+
:template,
|
106
|
+
:text_path,
|
107
|
+
:thread,
|
67
108
|
:time,
|
68
109
|
:title,
|
69
110
|
:track,
|
111
|
+
:tspan,
|
112
|
+
:u,
|
113
|
+
:use,
|
70
114
|
:var,
|
115
|
+
:view,
|
71
116
|
:wbr]
|
72
117
|
|
73
118
|
ADVANCED_ELEMENTS = [:text_field,
|
@@ -82,6 +127,7 @@ module Druid
|
|
82
127
|
:span,
|
83
128
|
:table,
|
84
129
|
:cell,
|
130
|
+
:row,
|
85
131
|
:image,
|
86
132
|
:form,
|
87
133
|
:list_item,
|
@@ -101,6 +147,7 @@ module Druid
|
|
101
147
|
:audio,
|
102
148
|
:video,
|
103
149
|
:b,
|
150
|
+
:i,
|
104
151
|
:svg]
|
105
152
|
|
106
153
|
def self.generate_locators(target)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Druid
|
2
|
+
class SectionCollection < Array
|
3
|
+
|
4
|
+
def find_by values_hash
|
5
|
+
find do |section|
|
6
|
+
values_hash.all? { |key, value| value === section.public_send(key) }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def select_by values_hash
|
11
|
+
matches = select do |section|
|
12
|
+
values_hash.all? { |key, value| value === section.public_send(key) }
|
13
|
+
end
|
14
|
+
self.class[*matches]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/druid/version.rb
CHANGED
@@ -205,7 +205,7 @@ describe Druid::Accessors do
|
|
205
205
|
|
206
206
|
it "should raise error when it does not have expected title" do
|
207
207
|
expect(driver).to receive(:title).and_return("Not Expected")
|
208
|
-
expect {druid.has_expected_title? }.to raise_error
|
208
|
+
expect {druid.has_expected_title? }.to raise_error "Expected title \'Expected Title\' instead of \'Not Expected\'"
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
@@ -225,6 +225,33 @@ describe Druid::Accessors do
|
|
225
225
|
end
|
226
226
|
end
|
227
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
|
+
|
228
255
|
describe "using default identifiers" do
|
229
256
|
class DefaultIdentifier
|
230
257
|
include Druid
|
@@ -699,6 +726,7 @@ describe Druid::Accessors do
|
|
699
726
|
context "when called on a page object" do
|
700
727
|
it "should generate accessor methods" do
|
701
728
|
expect(druid).to respond_to :logo_element
|
729
|
+
expect(druid).to respond_to :logo_loaded?
|
702
730
|
end
|
703
731
|
|
704
732
|
it "should call a block on the element method when present " do
|
data/spec/druid/druid_spec.rb
CHANGED
@@ -70,7 +70,7 @@ describe Druid do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
context "when created with a watir
|
73
|
+
context "when created with a watir browser" do
|
74
74
|
it "should include the Druid module" do
|
75
75
|
expect(druid).to be_kind_of Druid
|
76
76
|
end
|
@@ -84,6 +84,39 @@ describe Druid do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
context "when sent a missing method" do
|
88
|
+
it "should not respond to it if the @root_element doesn't exist" do
|
89
|
+
expect(nil).to respond_to :to_i
|
90
|
+
expect(druid.instance_variable_get(:@root_element)).to be nil
|
91
|
+
expect(druid).not_to respond_to :to_i
|
92
|
+
expect { druid.to_i }.to raise_error NoMethodError
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should respond to it if the @root_element exists and responds" do
|
96
|
+
expect(druid.instance_variable_get(:@root_element)).to be nil
|
97
|
+
expect(druid).not_to respond_to :bar
|
98
|
+
expect(druid).not_to respond_to :baz
|
99
|
+
class Foo
|
100
|
+
def bar
|
101
|
+
:bar_called
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def baz
|
107
|
+
end
|
108
|
+
end
|
109
|
+
druid.instance_variable_set(:@root_element, Foo.new)
|
110
|
+
|
111
|
+
expect(druid).to respond_to :bar
|
112
|
+
expect(druid).not_to respond_to :baz
|
113
|
+
expect(druid.bar).to eq :bar_called
|
114
|
+
expect { druid.baz }.to raise_error NoMethodError
|
115
|
+
expect(druid.respond_to?(:baz, true)).to be false
|
116
|
+
expect { druid.send(:baz) }.to raise_error NoMethodError
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
87
120
|
describe "page level functionality" do
|
88
121
|
context "when using PageObject" do
|
89
122
|
|
@@ -114,7 +147,7 @@ describe Druid do
|
|
114
147
|
end
|
115
148
|
|
116
149
|
it "should wait until a block returns true" do
|
117
|
-
expect(driver).to receive(:wait_until).with(5, "too long")
|
150
|
+
expect(driver).to receive(:wait_until).with(timeout: 5, message: "too long")
|
118
151
|
druid.wait_until(5, "too long")
|
119
152
|
end
|
120
153
|
|
@@ -251,7 +284,7 @@ describe Druid do
|
|
251
284
|
|
252
285
|
it "should use the overriden timeout value when set" do
|
253
286
|
Druid.default_page_wait = 10
|
254
|
-
expect(driver).to receive(:wait_until).with(10, nil)
|
287
|
+
expect(driver).to receive(:wait_until).with(timeout: 10, message: nil)
|
255
288
|
druid.wait_until
|
256
289
|
end
|
257
290
|
|
@@ -274,6 +274,28 @@ describe Druid::ElementLocators do
|
|
274
274
|
page.cell_elements
|
275
275
|
end
|
276
276
|
|
277
|
+
it "should find a table row" do
|
278
|
+
expect(driver).to receive(:tr).with(:id => 'blah').and_return(driver)
|
279
|
+
element = page.row_element(:id => 'blah')
|
280
|
+
expect(element).to be_instance_of Druid::Elements::TableRow
|
281
|
+
end
|
282
|
+
|
283
|
+
it "should find a table row using a default identifier" do
|
284
|
+
expect(driver).to receive(:tr).with(:index => 0).and_return(driver)
|
285
|
+
page.row_element
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should find all table row" do
|
289
|
+
expect(driver).to receive(:trs).with(:id => 'blah').and_return([driver])
|
290
|
+
elements = page.row_elements(:id => 'blah')
|
291
|
+
expect(elements[0]).to be_instance_of Druid::Elements::TableRow
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should find all table rows using no identifier" do
|
295
|
+
expect(driver).to receive(:trs).with({}).and_return([driver])
|
296
|
+
page.row_elements
|
297
|
+
end
|
298
|
+
|
277
299
|
it "should find an image element" do
|
278
300
|
expect(driver).to receive(:image).with(:id => 'blah').and_return(driver)
|
279
301
|
element = page.image_element(:id => 'blah')
|
@@ -703,4 +725,26 @@ describe Druid::ElementLocators do
|
|
703
725
|
page.b_elements
|
704
726
|
end
|
705
727
|
|
728
|
+
it "should find a i element" do
|
729
|
+
expect(driver).to receive(:i).with(:id => 'blah').and_return(driver)
|
730
|
+
element = page.i_element(:id => 'blah')
|
731
|
+
expect(element).to be_instance_of Druid::Elements::Italic
|
732
|
+
end
|
733
|
+
|
734
|
+
it "should find a i element using a default identifier" do
|
735
|
+
expect(driver).to receive(:i).with(:index => 0).and_return(driver)
|
736
|
+
page.i_element
|
737
|
+
end
|
738
|
+
|
739
|
+
it "should find all i elements" do
|
740
|
+
expect(driver).to receive(:is).with(:id => 'blah').and_return([driver])
|
741
|
+
elements = page.i_elements(:id => 'blah')
|
742
|
+
expect(elements[0]).to be_instance_of Druid::Elements::Italic
|
743
|
+
end
|
744
|
+
|
745
|
+
it "should find all b elements using no parameters" do
|
746
|
+
expect(driver).to receive(:is).with({}).and_return([driver])
|
747
|
+
page.i_elements
|
748
|
+
end
|
749
|
+
|
706
750
|
end
|