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,12 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::Bold do
|
|
5
|
+
let(:bold) { Druid::Elements::Bold}
|
|
6
|
+
|
|
7
|
+
describe "interface" do
|
|
8
|
+
it "should register with tag :b" do
|
|
9
|
+
expect(Druid::Elements.element_class_for(:b)).to eql Druid::Elements::Bold
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::Button do
|
|
5
|
+
|
|
6
|
+
describe "interface" do
|
|
7
|
+
it "should register with type :submit" do
|
|
8
|
+
expect(Druid::Elements.element_class_for(:input, :submit)).to be Druid::Elements::Button
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should register with type :image" do
|
|
12
|
+
expect(Druid::Elements.element_class_for(:input, :image)).to be Druid::Elements::Button
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should register with type :button" do
|
|
16
|
+
expect(Druid::Elements.element_class_for(:input, :button)).to be Druid::Elements::Button
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should register with type :reset" do
|
|
20
|
+
expect(Druid::Elements.element_class_for(:input, :reset)).to be Druid::Elements::Button
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::CheckBox do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
let(:element) { double 'element' }
|
|
7
|
+
let(:checkbox) { Druid::Elements::CheckBox.new(element) }
|
|
8
|
+
|
|
9
|
+
it "should register with type :checkbox" do
|
|
10
|
+
expect(Druid::Elements.element_class_for(:input, :checkbox)).to be Druid::Elements::CheckBox
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
require 'druid/elements'
|
|
2
|
+
|
|
3
|
+
describe Druid::Elements::Element do
|
|
4
|
+
let(:we) { double('we') }
|
|
5
|
+
let(:element) { Druid::Elements::Element.new(we) }
|
|
6
|
+
|
|
7
|
+
context "when handling unknown requests" do
|
|
8
|
+
it "should delegate to the driver element" do
|
|
9
|
+
expect(we).to receive(:do_this)
|
|
10
|
+
element.do_this
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "on a druid" do
|
|
15
|
+
it "should know when it is visible" do
|
|
16
|
+
expect(we).to receive(:present?).and_return(true)
|
|
17
|
+
expect(element.present?).to be true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should know when it is not visible" do
|
|
21
|
+
expect(we).to receive(:present?).and_return(false)
|
|
22
|
+
expect(element.present?).to be false
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should know when it exists" do
|
|
26
|
+
expect(we).to receive(:exist?).and_return(true)
|
|
27
|
+
expect(element.exist?).to be true
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should know when it does not exist" do
|
|
31
|
+
expect(we).to receive(:exist?).and_return(false)
|
|
32
|
+
expect(element.exist?).to be false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should be able to return the text contained in the element" do
|
|
36
|
+
expect(we).to receive(:text).and_return("my text")
|
|
37
|
+
expect(element.text).to eql "my text"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should know when it is not equal to another" do
|
|
41
|
+
expect(element).not_to eq 'not an element'
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should know when it is equal to another" do
|
|
45
|
+
expect(we).to receive(:==).and_return(true)
|
|
46
|
+
expect(element == element).to be true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should return its tag name" do
|
|
50
|
+
expect(we).to receive(:tag_name).and_return('h1')
|
|
51
|
+
expect(element.tag_name).to eql 'h1'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should know its value" do
|
|
55
|
+
expect(we).to receive(:value).and_return('value')
|
|
56
|
+
expect(element.value).to eql 'value'
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "should be clickable" do
|
|
60
|
+
expect(we).to receive(:click)
|
|
61
|
+
element.click
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should check if the element is visible" do
|
|
65
|
+
expect(we).to receive(:present?).and_return(false)
|
|
66
|
+
expect(we).to receive(:present?).and_return(true)
|
|
67
|
+
expect(element.check_visible).to be true
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should check if the element is present" do
|
|
71
|
+
# simulate Active Support's Object#present? being included
|
|
72
|
+
allow_any_instance_of(Object).to receive(:present?)
|
|
73
|
+
|
|
74
|
+
expect(we).to receive(:present?)
|
|
75
|
+
element.present?
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "should check if the element exists" do
|
|
79
|
+
expect(we).to receive(:exists?).and_return(false)
|
|
80
|
+
expect(we).to receive(:exists?).and_return(true)
|
|
81
|
+
expect(element.check_exist).to be true
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it "should be able to block until it is present" do
|
|
85
|
+
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
|
|
86
|
+
element.when_present(10)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should return the element when it is present" do
|
|
90
|
+
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
|
|
91
|
+
new_element = element.when_present(10)
|
|
92
|
+
expect(new_element).to eql element
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should use the overriden wait when set" do
|
|
96
|
+
Druid.default_element_wait = 20
|
|
97
|
+
allow(we).to receive(:wait_until).with(timeout: 20, message: "Element not present in 20 seconds")
|
|
98
|
+
element.when_present
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should be able to block until it is visible" do
|
|
102
|
+
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
|
|
103
|
+
allow(we).to receive(:displayed?).and_return(true)
|
|
104
|
+
new_element = element.when_visible(10)
|
|
105
|
+
expect(new_element).to eql element
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should be able to block until it is not visible" do
|
|
109
|
+
allow(we).to receive(:wait_while).with(timeout: 10, message: "Element still present in 10 seconds")
|
|
110
|
+
allow(we).to receive(:displayed?).and_return(false)
|
|
111
|
+
element.when_not_visible(10)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "should be able to block until a user define event fires true" do
|
|
115
|
+
allow(we).to receive(:wait_until).with(timeout: 10, message: "Element blah")
|
|
116
|
+
element.wait_until(10, "Element blah") {true}
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "should send keys to the element" do
|
|
120
|
+
expect(we).to receive(:send_keys).with([:control, 'a'])
|
|
121
|
+
element.send_keys([:control, 'a'])
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "should clear its' contents" do
|
|
125
|
+
expect(we).to receive(:clear)
|
|
126
|
+
element.clear
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should be double clickable" do
|
|
130
|
+
expect(we).to receive(:double_click)
|
|
131
|
+
element.double_click
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should be right clickable" do
|
|
135
|
+
expect(we).to receive(:right_click)
|
|
136
|
+
element.right_click
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "should get element's style" do
|
|
140
|
+
expect(we).to receive(:style).with('class').and_return('tim')
|
|
141
|
+
expect(element.style('class')).to eql "tim"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it "should know if an element is focused" do
|
|
145
|
+
expect(we).to receive(:focused?).and_return(true)
|
|
146
|
+
expect(element.focused?).to be true
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "should know if an element is not focuesd" do
|
|
150
|
+
expect(we).to receive(:focused?).and_return(false)
|
|
151
|
+
expect(element.focused?).to_not be true
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it "should be able to fire event" do
|
|
155
|
+
expect(we).to receive(:fire_event).with('onclick')
|
|
156
|
+
element.fire_event('onclick')
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it "should be able to focus element" do
|
|
160
|
+
expect(we).to receive(:focus)
|
|
161
|
+
element.focus
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it "should know if the element is disabled" do
|
|
165
|
+
expect(we).to receive(:enabled?).and_return(false)
|
|
166
|
+
expect(element).to be_disabled
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it "should be able to flash element" do
|
|
170
|
+
expect(we).to receive(:flash)
|
|
171
|
+
element.flash
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it "should return the outer html" do
|
|
175
|
+
expect(we).to receive(:outer_html).and_return("<div>blah</div>")
|
|
176
|
+
element.outer_html
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
it "should return the inner html" do
|
|
180
|
+
expect(we).to receive(:inner_html).and_return("blah")
|
|
181
|
+
element.inner_html
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it "should know if it is stale" do
|
|
185
|
+
expect(we).to receive(:stale?).and_return(false)
|
|
186
|
+
expect(element.stale?).to be false
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
context 'walking the dom' do
|
|
191
|
+
let(:found) { double('found').as_null_object }
|
|
192
|
+
|
|
193
|
+
before do
|
|
194
|
+
allow(found).to receive(:tag_name).and_return(:span)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it 'should find the parent object' do
|
|
198
|
+
expect(we).to receive(:parent).and_return(found)
|
|
199
|
+
object = element.parent
|
|
200
|
+
expect(object).to be_a(Druid::Elements::Span)
|
|
201
|
+
expect(object.tag_name).to eql :span
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it 'should find the proceeding sibling' do
|
|
205
|
+
expect(we).to receive(:preceding_sibling).and_return(found)
|
|
206
|
+
object = element.preceding_sibling
|
|
207
|
+
expect(object).to be_a(Druid::Elements::Span)
|
|
208
|
+
expect(object.tag_name).to eql :span
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
it 'should find the following sibling' do
|
|
212
|
+
expect(we).to receive(:following_sibling).and_return(found)
|
|
213
|
+
object = element.following_sibling
|
|
214
|
+
expect(object).to be_a(Druid::Elements::Span)
|
|
215
|
+
expect(object.tag_name).to eql :span
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it 'should find all of its siblings' do
|
|
219
|
+
expect(we).to receive(:siblings).and_return([found, found])
|
|
220
|
+
results = element.siblings
|
|
221
|
+
expect(results.size).to eql 2
|
|
222
|
+
expect(results[0]).to be_a(Druid::Elements::Span)
|
|
223
|
+
expect(results[1]).to be_a(Druid::Elements::Span)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
it 'should find all of its children' do
|
|
227
|
+
expect(we).to receive(:children).and_return([found, found])
|
|
228
|
+
results = element.children
|
|
229
|
+
expect(results.size).to eql 2
|
|
230
|
+
expect(results[0]).to be_a(Druid::Elements::Span)
|
|
231
|
+
expect(results[1]).to be_a(Druid::Elements::Span)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
it 'should find all of the preceding siblings' do
|
|
235
|
+
expect(we).to receive(:preceding_siblings).and_return([found, found])
|
|
236
|
+
results = element.preceding_siblings
|
|
237
|
+
expect(results.size).to eql 2
|
|
238
|
+
expect(results[0]).to be_a(Druid::Elements::Span)
|
|
239
|
+
expect(results[1]).to be_a(Druid::Elements::Span)
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
it 'should find all of the following siblings' do
|
|
243
|
+
expect(we).to receive(:following_siblings).and_return([found, found])
|
|
244
|
+
results = element.following_siblings
|
|
245
|
+
expect(results.size).to eql 2
|
|
246
|
+
expect(results[0]).to be_a(Druid::Elements::Span)
|
|
247
|
+
expect(results[1]).to be_a(Druid::Elements::Span)
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::FileField do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
let(:element) { double 'element' }
|
|
7
|
+
let(:file_field) { Druid::Elements::FileField.new(element) }
|
|
8
|
+
|
|
9
|
+
it "should register as type :file" do
|
|
10
|
+
expect(Druid::Elements.element_class_for(:input, :file)).to be Druid::Elements::FileField
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::Form do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
let(:element) { double 'element' }
|
|
7
|
+
let(:form) { Druid::Elements::Form.new(element) }
|
|
8
|
+
|
|
9
|
+
it "should submit a form" do
|
|
10
|
+
expect(element).to receive(:submit)
|
|
11
|
+
form.submit
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should register with tag_name :form" do
|
|
15
|
+
expect(Druid::Elements.element_class_for(:form)).to be Druid::Elements::Form
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::Heading do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
it "should register with tag :h1" do
|
|
7
|
+
expect(Druid::Elements.element_class_for(:h1)).to be Druid::Elements::Heading
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should register with tag :h2" do
|
|
11
|
+
expect(Druid::Elements.element_class_for(:h2)).to be Druid::Elements::Heading
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should register with tag :h3" do
|
|
15
|
+
expect(Druid::Elements.element_class_for(:h3)).to be Druid::Elements::Heading
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should register with tag :h4" do
|
|
19
|
+
expect(Druid::Elements.element_class_for(:h4)).to be Druid::Elements::Heading
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should register with tag :h5" do
|
|
23
|
+
expect(Druid::Elements.element_class_for(:h5)).to be Druid::Elements::Heading
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should register with tag :h6" do
|
|
27
|
+
expect(Druid::Elements.element_class_for(:h6)).to be Druid::Elements::Heading
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::HiddenField do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
it "should register with type :hidden" do
|
|
7
|
+
expect(Druid::Elements.element_class_for(:input, :hidden)).to be Druid::Elements::HiddenField
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::Image do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
let(:element) { 'element' }
|
|
7
|
+
let(:image) { Druid::Elements::Image.new(element) }
|
|
8
|
+
|
|
9
|
+
it "should know the image width" do
|
|
10
|
+
expect(element).to receive(:width).and_return(100)
|
|
11
|
+
expect(image.width).to eql 100
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "should know the image height" do
|
|
15
|
+
expect(element).to receive(:height).and_return(120)
|
|
16
|
+
expect(image.height).to eql 120
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should register with tag_name :img" do
|
|
20
|
+
expect(Druid::Elements.element_class_for(:img)).to be Druid::Elements::Image
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Druid::Elements::Italic do
|
|
4
|
+
let(:italic) { Druid::Elements::Italic}
|
|
5
|
+
|
|
6
|
+
describe "interface" do
|
|
7
|
+
it "should register with tag :i" do
|
|
8
|
+
expect(Druid::Elements.element_class_for(:i)).to eql Druid::Elements::Italic
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Druid::Elements::Media do
|
|
4
|
+
let(:element) { double 'element' }
|
|
5
|
+
let(:media) { Druid::Elements::Media.new(element) }
|
|
6
|
+
|
|
7
|
+
it "should return controls" do
|
|
8
|
+
expect(media).to receive(:attribute).with(:controls).and_return(true)
|
|
9
|
+
expect(media.has_controls?).to eq(true)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::Option do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
it "should register as tag_name :option" do
|
|
7
|
+
expect(Druid::Elements.element_class_for(:option)).to be Druid::Elements::Option
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe "interacting with the option" do
|
|
13
|
+
let(:we) { double 'we' }
|
|
14
|
+
let(:element) { Druid::Elements::Option.new(we) }
|
|
15
|
+
|
|
16
|
+
it "should know if it is selected" do
|
|
17
|
+
expect(we).to receive(:selected?).and_return true
|
|
18
|
+
expect(element.selected?).to be true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::OrderedList do
|
|
5
|
+
let(:ol) { Druid::Elements::OrderedList }
|
|
6
|
+
|
|
7
|
+
describe "interface" do
|
|
8
|
+
let(:ol_element) { double('ol_element').as_null_object }
|
|
9
|
+
let(:li_element) { double('li_element') }
|
|
10
|
+
|
|
11
|
+
it "should register as tag_name :ol" do
|
|
12
|
+
expect(Druid::Elements.element_class_for(:ol)).to be Druid::Elements::OrderedList
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context "for sub methods" do
|
|
16
|
+
before(:each) do
|
|
17
|
+
allow(ol_element).to receive(:tag_name).and_return(:ol)
|
|
18
|
+
end
|
|
19
|
+
let(:ol) { ol = Druid::Elements::OrderedList.new(ol_element) }
|
|
20
|
+
|
|
21
|
+
it "should return a list item when indexed" do
|
|
22
|
+
allow(ol_element).to receive(:children).and_return([ol_element, ol_element])
|
|
23
|
+
ol[1]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should know how many list items it contains" do
|
|
27
|
+
allow(ol_element).to receive(:children).and_return([ol_element])
|
|
28
|
+
expect(ol.items).to eql 1
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should iterate over the list items" do
|
|
32
|
+
expect(ol).to receive(:list_items).and_return(Array.new(5, ol_element))
|
|
33
|
+
expect(ol.items).to eql 5
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/page_factory'
|
|
3
|
+
|
|
4
|
+
class FactoryTestDruid
|
|
5
|
+
include Druid
|
|
6
|
+
page_url "http://www.baidu.com"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class TestWorldOne
|
|
10
|
+
include Druid::PageFactory
|
|
11
|
+
|
|
12
|
+
attr_accessor :driver
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe Druid::PageFactory do
|
|
16
|
+
before(:each) do
|
|
17
|
+
@world = TestWorldOne.new
|
|
18
|
+
@world.driver = mock_driver
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should create and visit a new page" do
|
|
22
|
+
expect(@world.driver).to receive(:goto)
|
|
23
|
+
@world.visit_page FactoryTestDruid do |page|
|
|
24
|
+
expect(page).to be_instance_of FactoryTestDruid
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should create a new page object and execute a block" do
|
|
29
|
+
expect(@world.driver).not_to receive(:goto)
|
|
30
|
+
@world.on_page FactoryTestDruid do |page|
|
|
31
|
+
expect(page).to be_instance_of FactoryTestDruid
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should set an instance variable that can be used outside of the block" do
|
|
36
|
+
page = @world.on_page FactoryTestDruid
|
|
37
|
+
current_page = @world.instance_variable_get "@current_page"
|
|
38
|
+
expect(current_page).to eq page
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::Paragraph do
|
|
5
|
+
let(:paragraph) { Druid::Elements::Paragraph }
|
|
6
|
+
|
|
7
|
+
describe "interface" do
|
|
8
|
+
it "should register with type :checkbox" do
|
|
9
|
+
expect(Druid::Elements.element_class_for(:p)).to be Druid::Elements::Paragraph
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::RadioButton do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
let(:element) { double("element") }
|
|
7
|
+
let(:driver) { double("driver") }
|
|
8
|
+
let(:radio) { Druid::Elements::RadioButton.new(element)}
|
|
9
|
+
|
|
10
|
+
it "should register as type :radio" do
|
|
11
|
+
expect(Druid::Elements.element_class_for(:input, :radio)).to be Druid::Elements::RadioButton
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'druid/elements'
|
|
3
|
+
|
|
4
|
+
describe Druid::Elements::SelectList do
|
|
5
|
+
describe "interface" do
|
|
6
|
+
let(:element) { double 'element' }
|
|
7
|
+
let(:opts) { [element, element] }
|
|
8
|
+
let(:select_list) { Druid::Elements::SelectList.new(element) }
|
|
9
|
+
|
|
10
|
+
it "should return an option when indexed" do
|
|
11
|
+
expect(element).to receive(:options).with(no_args).and_return(opts)
|
|
12
|
+
expect(select_list[1]).to be_instance_of Druid::Elements::Option
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "should retrieve all values of select_list" do
|
|
16
|
+
expect(element).to receive(:options).with(no_args).and_return(opts)
|
|
17
|
+
expect(select_list.options.size).to eql 2
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should select an element" do
|
|
21
|
+
expect(element).to receive(:select).with('test')
|
|
22
|
+
select_list.select('test')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should register with tag_name :select" do
|
|
26
|
+
expect(Druid::Elements.element_class_for(:select)).to be Druid::Elements::SelectList
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should return an array of selected options" do
|
|
30
|
+
allow(element).to receive(:selected_options).and_return(opts)
|
|
31
|
+
allow(element).to receive(:text).and_return(element)
|
|
32
|
+
expect(select_list.selected_options).to eql opts
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "should be able to get the value for the selected options" do
|
|
36
|
+
allow(element).to receive(:selected_options).and_return(opts)
|
|
37
|
+
allow(element).to receive(:value).and_return(element)
|
|
38
|
+
expect(select_list.selected_values).to eql opts
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should know if it includes some value" do
|
|
42
|
+
expect(element).to receive(:include?).with('blah').and_return(true)
|
|
43
|
+
select_list.include?('blah')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should know if an option is selected" do
|
|
47
|
+
expect(element).to receive(:selected?).with("blah").and_return(true)
|
|
48
|
+
select_list.selected?('blah')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|