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,295 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
class TestDruid
|
|
4
|
+
include Druid
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
describe Druid do
|
|
8
|
+
let(:driver) { mock_driver }
|
|
9
|
+
let(:druid) { TestDruid.new(driver) }
|
|
10
|
+
|
|
11
|
+
context "setting values on the Druid module" do
|
|
12
|
+
it "should set the javascript framework" do
|
|
13
|
+
expect(Druid::JavascriptFrameworkFacade).to receive(:framework=)
|
|
14
|
+
Druid.javascript_framework = :foo
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should add the javascript framework" do
|
|
18
|
+
expect(Druid::JavascriptFrameworkFacade).to receive(:add_framework)
|
|
19
|
+
Druid.add_framework(:foo, :bar)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "should set a default page wait value" do
|
|
23
|
+
Druid.default_page_wait = 20
|
|
24
|
+
wait = Druid.instance_variable_get("@page_wait")
|
|
25
|
+
expect(wait).to eql 20
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "should provide the default page wait value" do
|
|
29
|
+
Druid.instance_variable_set("@page_wait", 10)
|
|
30
|
+
expect(Druid.default_page_wait).to eql 10
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should default the page wait value to 30" do
|
|
34
|
+
Druid.instance_variable_set("@page_wait", nil)
|
|
35
|
+
expect(Druid.default_page_wait).to eql 30
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "should set the default element wait value" do
|
|
39
|
+
Druid.default_element_wait = 20
|
|
40
|
+
wait = Druid.instance_variable_get("@element_wait")
|
|
41
|
+
expect(wait).to eql 20
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should provide the default element wait value" do
|
|
45
|
+
Druid.instance_variable_set("@element_wait", 10)
|
|
46
|
+
expect(Druid.default_element_wait).to eql 10
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "should default the element wait to 5" do
|
|
50
|
+
Druid.instance_variable_set("@element_wait", nil)
|
|
51
|
+
expect(Druid.default_element_wait).to eql 5
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "setting values on the Druid class instance" do
|
|
56
|
+
it "should set the params value" do
|
|
57
|
+
TestDruid.params = {:some => :value}
|
|
58
|
+
params = TestDruid.instance_variable_get("@params")
|
|
59
|
+
expect(params[:some]).to eql :value
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should provide the params value" do
|
|
63
|
+
TestDruid.instance_variable_set("@params", {:value => :updated})
|
|
64
|
+
expect(TestDruid.params[:value]).to eql :updated
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should default the params to an empty hash" do
|
|
68
|
+
TestDruid.instance_variable_set("@params", nil)
|
|
69
|
+
expect(TestDruid.params).to eql Hash.new
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context "when created with a watir browser" do
|
|
74
|
+
it "should include the Druid module" do
|
|
75
|
+
expect(druid).to be_kind_of Druid
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
context "when created with an object we do not understand" do
|
|
80
|
+
it "should throw an error" do
|
|
81
|
+
expect {
|
|
82
|
+
TestDruid.new("blah")
|
|
83
|
+
}.to raise_error 'expect Watir::Browser or Watir::HTMLElement'
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context "when sent a missing method" do
|
|
88
|
+
|
|
89
|
+
it "should respond to it if the @root_element exists and responds" do
|
|
90
|
+
expect(druid).not_to respond_to :bar
|
|
91
|
+
expect(druid).not_to respond_to :baz
|
|
92
|
+
class Foo; def bar; :bar_called; end; private; def baz; end; end
|
|
93
|
+
druid.instance_variable_set(:@root_element, Foo.new)
|
|
94
|
+
expect(druid).to respond_to :bar
|
|
95
|
+
expect(druid).not_to respond_to :baz
|
|
96
|
+
expect(druid.bar).to eq :bar_called
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe "page level functionality" do
|
|
101
|
+
context "when using PageObject" do
|
|
102
|
+
|
|
103
|
+
it "should display the page text" do
|
|
104
|
+
# expect(driver).to receive(:element).and_return(driver)
|
|
105
|
+
expect(driver).to receive(:text).and_return("driver text")
|
|
106
|
+
expect(druid.text).to eql "driver text"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "should display the html of the page" do
|
|
110
|
+
expect(driver).to receive(:html).and_return("<html>Some Sample HTML</html>")
|
|
111
|
+
expect(druid.html).to eql "<html>Some Sample HTML</html>"
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "should display the title of the page" do
|
|
115
|
+
expect(driver).to receive(:title).and_return("I am the title of a page")
|
|
116
|
+
expect(druid.title).to eql "I am the title of a page"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
it "should be able to navigate to a page" do
|
|
120
|
+
expect(driver).to receive(:goto).with("www.baidu.com")
|
|
121
|
+
druid.navigate_to("www.baidu.com")
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "should know it's current url" do
|
|
125
|
+
expect(driver).to receive(:url).and_return("www.baidu.com")
|
|
126
|
+
expect(druid.current_url).to eql "www.baidu.com"
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "should wait until a block returns true" do
|
|
130
|
+
expect(driver).to receive(:wait_until).with(timeout: 5, message: "too long")
|
|
131
|
+
druid.wait_until(5, "too long")
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it "should retrieve the text from alert popup" do
|
|
135
|
+
allow(driver).to receive_message_chain(:alert, :exists?).and_return(true)
|
|
136
|
+
allow(driver).to receive_message_chain(:alert, :text).and_return('I am an alert')
|
|
137
|
+
expect(driver).to receive_message_chain(:alert, :ok)
|
|
138
|
+
msg = druid.alert do
|
|
139
|
+
end
|
|
140
|
+
expect(msg).to eql 'I am an alert'
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "should retrieve the text from confirm popup" do
|
|
144
|
+
allow(driver).to receive_message_chain(:alert, :exists?).and_return(true)
|
|
145
|
+
allow(driver).to receive_message_chain(:alert, :text).and_return('I am an confirm')
|
|
146
|
+
expect(driver).to receive_message_chain(:alert, :ok)
|
|
147
|
+
msg = druid.confirm(true) do
|
|
148
|
+
end
|
|
149
|
+
expect(msg).to eql 'I am an confirm'
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it "should retrieve the text from prompt popup" do
|
|
153
|
+
allow(driver).to receive_message_chain(:alert, :exists?).and_return(true)
|
|
154
|
+
allow(driver).to receive_message_chain(:alert, :text).and_return('I am an prompt')
|
|
155
|
+
allow(driver).to receive_message_chain(:alert, :set).with("blah")
|
|
156
|
+
expect(driver).to receive_message_chain(:alert, :ok)
|
|
157
|
+
msg = druid.prompt("blah") do
|
|
158
|
+
end
|
|
159
|
+
expect(msg).to eql "I am an prompt"
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it "should switch to a new window with a given title" do
|
|
163
|
+
expect(driver).to receive(:window).with(:title => "My Title").and_return(driver)
|
|
164
|
+
expect(driver).to receive(:use)
|
|
165
|
+
druid.attach_to_window(:title => "My Title")
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it "should switch to a new window with a given index" do
|
|
169
|
+
expect(driver).to receive(:window).with(:index => 1).and_return(driver)
|
|
170
|
+
expect(driver).to receive(:use)
|
|
171
|
+
druid.attach_to_window(:index => 1)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it "should switch to a new window witha given url" do
|
|
175
|
+
expect(driver).to receive(:window).with(:url => /success\.html/).and_return(driver)
|
|
176
|
+
expect(driver).to receive(:use)
|
|
177
|
+
druid.attach_to_window(:url => "success.html")
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it "should refresh the page contents" do
|
|
181
|
+
expect(driver).to receive(:refresh)
|
|
182
|
+
druid.refresh
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it "should wait document load completely" do
|
|
186
|
+
expect(driver).to receive(:wait)
|
|
187
|
+
druid.wait
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it "should know how to go back" do
|
|
191
|
+
expect(driver).to receive(:back)
|
|
192
|
+
druid.back
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it "should know how to go forward" do
|
|
196
|
+
expect(driver).to receive(:forward)
|
|
197
|
+
druid.forward
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
it "should try a second time after sleeping when attach to window fails" do
|
|
201
|
+
expect(driver).to receive(:window).once.and_return(driver)
|
|
202
|
+
expect(driver).to receive(:use).once.and_throw "error"
|
|
203
|
+
expect(driver).to receive(:window).and_return(driver)
|
|
204
|
+
expect(driver).to receive(:use)
|
|
205
|
+
druid.attach_to_window(:value => 'tim')
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
it "should call intialize_page if it exists" do
|
|
209
|
+
class CallbackPage
|
|
210
|
+
include Druid
|
|
211
|
+
attr_reader :initialize_page_called
|
|
212
|
+
|
|
213
|
+
def initialize_page
|
|
214
|
+
@initialize_page_called = true
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
page = CallbackPage.new(driver)
|
|
219
|
+
expect(page.initialize_page_called).to be true
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
it "should call initialize_accessors if it exists" do
|
|
223
|
+
class CallbackPage
|
|
224
|
+
include Druid
|
|
225
|
+
attr_reader :initialize_accessors_called
|
|
226
|
+
|
|
227
|
+
def initialize_accessors
|
|
228
|
+
@initialize_accessors_called = true
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
@page = CallbackPage.new(driver)
|
|
233
|
+
expect(@page.initialize_accessors_called).to be true
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
it "should call initialize_accessors before initialize_page if both exist" do
|
|
237
|
+
class CallbackPage
|
|
238
|
+
include Druid
|
|
239
|
+
attr_reader :initialize_page, :initialize_accessors
|
|
240
|
+
|
|
241
|
+
def initialize_page
|
|
242
|
+
@initialize_page = Time.now
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def initialize_accessors
|
|
246
|
+
@initialize_accessors = Time.now
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
@page = CallbackPage.new(driver)
|
|
251
|
+
expect(@page.initialize_accessors.usec).to be <= @page.initialize_page.usec
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
it "should convert a modal popup to a window" do
|
|
255
|
+
expect(driver).to receive(:execute_script)
|
|
256
|
+
druid.modal_dialog {}
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
it "should know how to handle cookies" do
|
|
260
|
+
expect(driver).to receive(:cookies).and_return([])
|
|
261
|
+
druid.cookies
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
it "should be able to save a screenshot" do
|
|
265
|
+
expect(driver).to receive_message_chain(:screenshot,:save)
|
|
266
|
+
druid.save_screenshot('tim.png')
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
it "should use the overriden timeout value when set" do
|
|
270
|
+
Druid.default_page_wait = 10
|
|
271
|
+
expect(driver).to receive(:wait_until).with(timeout: 10, message: nil)
|
|
272
|
+
druid.wait_until
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it "should wait until there are no pending ajax requests" do
|
|
276
|
+
expect(Druid::JavascriptFrameworkFacade).to receive(:pending_requests).and_return('pending requests')
|
|
277
|
+
expect(driver).to receive(:execute_script).with('pending requests').and_return(0)
|
|
278
|
+
druid.wait_for_ajax
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
it "should execute javascript on the browser" do
|
|
282
|
+
expect(driver).to receive(:execute_script).and_return("abc")
|
|
283
|
+
expect(druid.execute_script("333")).to eql "abc"
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
it "should know which element has focus" do
|
|
287
|
+
expect(driver).to receive(:execute_script).and_return(driver)
|
|
288
|
+
expect(driver).to receive(:tag_name).twice.and_return(:input)
|
|
289
|
+
expect(driver).to receive(:type).and_return(:submit)
|
|
290
|
+
expect(druid.element_with_focus.class).to eql Druid::Elements::Button
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
end
|