druid-ts 1.1.8 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +27 -0
- data/features/bold.feature +21 -0
- data/features/element.feature +7 -0
- data/features/frames.feature +15 -0
- data/features/html/frames.html +3 -3
- data/features/html/iframes.html +2 -2
- data/features/html/multi_elements.html +1 -0
- data/features/html/static_elements.html +25 -8
- data/features/javascript.feature +10 -1
- data/features/link.feature +4 -0
- data/features/multi_elements.feature +6 -0
- data/features/radio_button_group.feature +28 -0
- data/features/section.feature +128 -0
- data/features/select_list.feature +4 -0
- data/features/step_definations/bold_steps.rb +11 -0
- data/features/step_definations/element_steps.rb +8 -0
- data/features/step_definations/frame_steps.rb +53 -11
- data/features/step_definations/javasript_steps.rb +9 -0
- data/features/step_definations/link_steps.rb +8 -0
- data/features/step_definations/multi_elements_steps.rb +13 -0
- data/features/step_definations/radio_button_group_steps.rb +32 -0
- data/features/step_definations/section_steps.rb +262 -0
- data/features/step_definations/table_steps.rb +9 -0
- data/features/support/env.rb +1 -0
- data/features/support/page.rb +16 -5
- data/features/table.feature +18 -14
- data/lib/druid.rb +42 -30
- data/lib/druid/accessors.rb +188 -55
- data/lib/druid/assist.rb +46 -4
- data/lib/druid/elements.rb +1 -0
- data/lib/druid/elements/bold.rb +8 -0
- data/lib/druid/elements/element.rb +16 -3
- data/lib/druid/elements/link.rb +7 -0
- data/lib/druid/elements/radio_button.rb +0 -7
- data/lib/druid/elements/select_list.rb +2 -2
- data/lib/druid/elements/table.rb +7 -0
- data/lib/druid/javascript/angularjs.rb +12 -0
- data/lib/druid/javascript_framework_facade.rb +5 -3
- data/lib/druid/locator_generator.rb +1 -0
- data/lib/druid/page_factory.rb +1 -0
- data/lib/druid/page_populator.rb +10 -1
- data/lib/druid/sections.rb +29 -0
- data/lib/druid/version.rb +1 -1
- data/spec/druid/accessors_spec.rb +79 -13
- data/spec/druid/druid_spec.rb +2 -1
- data/spec/druid/element_locators_spec.rb +26 -4
- data/spec/druid/elements/bold_spec.rb +21 -0
- data/spec/druid/elements/link_spec.rb +1 -1
- data/spec/druid/elements/page_factory_spec.rb +2 -2
- data/spec/druid/elements/radio_button_spec.rb +0 -5
- data/spec/druid/elements/select_list_spec.rb +3 -3
- data/spec/druid/page_factory_spec.rb +15 -15
- data/spec/druid/page_populator_spec.rb +4 -4
- data/spec/druid/page_section_spec.rb +61 -0
- data/spec/spec_helper.rb +1 -0
- metadata +20 -1
data/spec/druid/druid_spec.rb
CHANGED
@@ -80,7 +80,7 @@ describe Druid do
|
|
80
80
|
it "should throw an error" do
|
81
81
|
expect {
|
82
82
|
TestDruid.new("blah")
|
83
|
-
}.to raise_error 'expect Watir::Browser'
|
83
|
+
}.to raise_error 'expect Watir::Browser or Watir::HTMLElement'
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -88,6 +88,7 @@ describe Druid do
|
|
88
88
|
context "when using PageObject" do
|
89
89
|
|
90
90
|
it "should display the page text" do
|
91
|
+
# expect(driver).to receive(:element).and_return(driver)
|
91
92
|
expect(driver).to receive(:text).and_return("driver text")
|
92
93
|
expect(druid.text).to eql "driver text"
|
93
94
|
end
|
@@ -10,8 +10,8 @@ describe Druid::ElementLocators do
|
|
10
10
|
|
11
11
|
it "should find a button element" do
|
12
12
|
expect(driver).to receive(:button).with(:id => 'blah').and_return(driver)
|
13
|
-
|
14
|
-
expect(
|
13
|
+
element = page.button_element(:id => 'blah')
|
14
|
+
expect(element).to be_instance_of Druid::Elements::Button
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should find a button element using a default identifier" do
|
@@ -32,8 +32,8 @@ describe Druid::ElementLocators do
|
|
32
32
|
|
33
33
|
it "should find a text field element" do
|
34
34
|
expect(driver).to receive(:text_field).with(:id => 'blah').and_return(driver)
|
35
|
-
|
36
|
-
expect(
|
35
|
+
element = page.text_field_element(:id => 'blah')
|
36
|
+
expect(element).to be_instance_of Druid::Elements::TextField
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should find a text field element using a default identifier" do
|
@@ -681,4 +681,26 @@ describe Druid::ElementLocators do
|
|
681
681
|
page.video_elements
|
682
682
|
end
|
683
683
|
|
684
|
+
it "should find a b element" do
|
685
|
+
expect(driver).to receive(:b).with(:id => 'blah').and_return(driver)
|
686
|
+
element = page.b_element(:id => 'blah')
|
687
|
+
expect(element).to be_instance_of Druid::Elements::Bold
|
688
|
+
end
|
689
|
+
|
690
|
+
it "should find a b element using a default identifier" do
|
691
|
+
expect(driver).to receive(:b).with(:index => 0).and_return(driver)
|
692
|
+
page.b_element
|
693
|
+
end
|
694
|
+
|
695
|
+
it "should find all b elements" do
|
696
|
+
expect(driver).to receive(:bs).with(:id => 'blah').and_return([driver])
|
697
|
+
elements = page.b_elements(:id => 'blah')
|
698
|
+
expect(elements[0]).to be_instance_of Druid::Elements::Bold
|
699
|
+
end
|
700
|
+
|
701
|
+
it "should find all b elements using no parameters" do
|
702
|
+
expect(driver).to receive(:bs).with({}).and_return([driver])
|
703
|
+
page.b_elements
|
704
|
+
end
|
705
|
+
|
684
706
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'druid/elements'
|
3
|
+
|
4
|
+
describe Druid::Elements::Bold do
|
5
|
+
let(:bold) { Druid::Elements::Bold}
|
6
|
+
|
7
|
+
describe "when mapping how to find an element" do
|
8
|
+
it "should map watir types to same" do
|
9
|
+
[:class, :id, :idenx, :name, :xpath, :css].each do |t|
|
10
|
+
identifier = bold.identifier_for t => 'value'
|
11
|
+
expect(identifier.keys.first).to eql t
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "interface" do
|
17
|
+
it "should register with tag :b" do
|
18
|
+
expect(Druid::Elements.element_class_for(:b)).to eql Druid::Elements::Bold
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -4,7 +4,7 @@ require 'druid/elements'
|
|
4
4
|
describe Druid::Elements::Link do
|
5
5
|
describe "when mapping how to find an element" do
|
6
6
|
it "should map watir types to same" do
|
7
|
-
[:class, :href, :id, :name, :text, :xpath, :css, :title].each do |t|
|
7
|
+
[:class, :href, :id, :index, :name, :text, :xpath, :css, :title].each do |t|
|
8
8
|
identifier = Druid::Elements::Link.identifier_for t => 'value'
|
9
9
|
expect(identifier.keys.first).to eql t
|
10
10
|
end
|
@@ -6,7 +6,7 @@ class FactoryTestDruid
|
|
6
6
|
page_url "http://www.baidu.com"
|
7
7
|
end
|
8
8
|
|
9
|
-
class
|
9
|
+
class TestWorldOne
|
10
10
|
include Druid::PageFactory
|
11
11
|
|
12
12
|
attr_accessor :driver
|
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
describe Druid::PageFactory do
|
16
16
|
before(:each) do
|
17
|
-
@world =
|
17
|
+
@world = TestWorldOne.new
|
18
18
|
@world.driver = mock_driver
|
19
19
|
end
|
20
20
|
|
@@ -17,13 +17,13 @@ describe Druid::Elements::SelectList do
|
|
17
17
|
let(:select_list) { Druid::Elements::SelectList.new(element) }
|
18
18
|
|
19
19
|
it "should return an option when indexed" do
|
20
|
-
expect(element).to
|
20
|
+
expect(element).to receive(:options).with(no_args).and_return(opts)
|
21
21
|
expect(select_list[1]).to be_instance_of Druid::Elements::Option
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should retrieve all values of select_list" do
|
25
|
-
expect(element).to receive(:options).and_return(
|
26
|
-
expect(select_list.options).to eql
|
25
|
+
expect(element).to receive(:options).with(no_args).and_return(opts)
|
26
|
+
expect(select_list.options.size).to eql 2
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should select an element" do
|
@@ -26,9 +26,15 @@ module ContainingModule
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
class
|
30
|
-
|
29
|
+
class WorldSuper
|
30
|
+
attr_reader :super_called
|
31
|
+
def on_page(cls, params={}, visit=false, &block)
|
32
|
+
@super_called = true
|
33
|
+
end
|
34
|
+
end
|
31
35
|
|
36
|
+
class TestWorld < WorldSuper
|
37
|
+
include Druid::PageFactory
|
32
38
|
attr_accessor :driver
|
33
39
|
attr_accessor :current_page
|
34
40
|
end
|
@@ -41,6 +47,13 @@ describe Druid::PageFactory do
|
|
41
47
|
driver = world.driver
|
42
48
|
end
|
43
49
|
|
50
|
+
it "should call super when non druid class passed" do
|
51
|
+
class NoDruid
|
52
|
+
end
|
53
|
+
world.on(NoDruid)
|
54
|
+
expect(world.super_called).to be true
|
55
|
+
end
|
56
|
+
|
44
57
|
it "should create a new page object and execute a block" do
|
45
58
|
expect(driver).not_to receive(:goto)
|
46
59
|
world.on_page FactoryTestDruid do |page|
|
@@ -219,17 +232,4 @@ describe Druid::PageFactory do
|
|
219
232
|
expect{world.navigate_to(AnotherPage)}.to raise_error
|
220
233
|
end
|
221
234
|
|
222
|
-
it "should know how to continue routing from a location" do
|
223
|
-
Druid::PageFactory.routes = {:default => [[FactoryTestDruid, :a_method], [AnotherPage, :b_method], [YetAnotherPage, :c_method]]}
|
224
|
-
world.current_page = FactoryTestDruid.new(driver)
|
225
|
-
f_page = FactoryTestDruid.new(driver)
|
226
|
-
allow(FactoryTestDruid).to receive(:new).with(driver,false).and_return(f_page)
|
227
|
-
allow(f_page).to receive(:respond_to?).with(:a_method).and_return(true)
|
228
|
-
allow(f_page).to receive(:a_method)
|
229
|
-
a_page = AnotherPage.new(driver)
|
230
|
-
allow(AnotherPage).to receive(:new).with(driver,false).and_return(a_page)
|
231
|
-
allow(a_page).to receive(:respond_to?).with(:b_method).and_return(true)
|
232
|
-
allow(a_page).to receive(:b_method)
|
233
|
-
expect(world.continue_navigation_to(YetAnotherPage).class).to eql YetAnotherPage
|
234
|
-
end
|
235
235
|
end
|
@@ -9,6 +9,7 @@ class DruidPagePopulator
|
|
9
9
|
checkbox(:cb, :id => 'id')
|
10
10
|
radio_button(:rb, :id => 'id')
|
11
11
|
file_field(:ff, :id => 'id')
|
12
|
+
radio_button_group(:rbg, :id => 'id')
|
12
13
|
end
|
13
14
|
|
14
15
|
describe Druid::PagePopulator do
|
@@ -72,10 +73,9 @@ describe Druid::PagePopulator do
|
|
72
73
|
druid.populate_page_with('rb' => true)
|
73
74
|
end
|
74
75
|
|
75
|
-
it "should
|
76
|
-
expect(druid).to receive(:
|
77
|
-
|
78
|
-
druid.populate_page_with('rb' => false)
|
76
|
+
it "should select the correct element from a radio button group" do
|
77
|
+
expect(druid).to receive(:select_rbg).with('blah')
|
78
|
+
druid.populate_page_with('rbg' => 'blah')
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should not populate a checkbox if it is disabled" do
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Container
|
4
|
+
include Druid
|
5
|
+
end
|
6
|
+
|
7
|
+
class SectionsPage
|
8
|
+
include Druid
|
9
|
+
|
10
|
+
page_section(:container, Container, :id => 'blah')
|
11
|
+
page_sections(:containers, Container, :class => 'foo')
|
12
|
+
end
|
13
|
+
|
14
|
+
describe Druid::Accessors do
|
15
|
+
context "when using watir" do
|
16
|
+
let(:driver) { mock_driver }
|
17
|
+
let(:druid) { SectionsPage.new(driver) }
|
18
|
+
|
19
|
+
it "it should find a page section" do
|
20
|
+
expect(driver).to receive(:element).with(:id => 'blah').and_return(driver)
|
21
|
+
section = druid.container
|
22
|
+
expect(section).to be_instance_of Container
|
23
|
+
end
|
24
|
+
|
25
|
+
it "it should find page sections" do
|
26
|
+
expect(driver).to receive(:elements).with(:class => 'foo').and_return([driver, driver])
|
27
|
+
sections = druid.containers
|
28
|
+
expect(sections).to be_instance_of Druid::SectionCollection
|
29
|
+
sections.each do |section|
|
30
|
+
expect(section).to be_instance_of Container
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe Druid::SectionCollection do
|
36
|
+
ContainedItem = Struct.new(:type, :name)
|
37
|
+
let(:section_collection) do
|
38
|
+
contained_items = [ContainedItem.new(:sandwich, :reuben), ContainedItem.new(:soup, :lobstar_bisque), ContainedItem.new(:sandwich, :dagwood)]
|
39
|
+
Druid::SectionCollection.new(contained_items)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should be indexed to the sections" do
|
43
|
+
expect(section_collection[0]).to be_an_instance_of ContainedItem
|
44
|
+
expect(section_collection[-1]).to be_an_instance_of ContainedItem
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should be able to iterate over the sections" do
|
48
|
+
section_collection.each do |section|
|
49
|
+
expect(section).to be_an_instance_of ContainedItem
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should find a section by one of its values" do
|
54
|
+
expect(section_collection.find_by(name: :dagwood).name).to eq :dagwood
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should find all sections matching a value" do
|
58
|
+
expect(section_collection.select_by(type: :sandwich).map(&:type)).to eq [:sandwich, :sandwich]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: druid-ts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sheng
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- features/area.feature
|
101
101
|
- features/async.feature
|
102
102
|
- features/audio.feature
|
103
|
+
- features/bold.feature
|
103
104
|
- features/button.feature
|
104
105
|
- features/canvas.feature
|
105
106
|
- features/checkbox.feature
|
@@ -148,6 +149,7 @@ files:
|
|
148
149
|
- features/page_level_actions.feature
|
149
150
|
- features/paragraph.feature
|
150
151
|
- features/radio_button.feature
|
152
|
+
- features/radio_button_group.feature
|
151
153
|
- features/sample-app/public/jquery-1.3.2.js
|
152
154
|
- features/sample-app/public/jquery.html
|
153
155
|
- features/sample-app/public/movie.mp4
|
@@ -155,11 +157,13 @@ files:
|
|
155
157
|
- features/sample-app/public/prototype-1.6.0.3.js
|
156
158
|
- features/sample-app/public/prototype.html
|
157
159
|
- features/sample-app/sample_app.rb
|
160
|
+
- features/section.feature
|
158
161
|
- features/select_list.feature
|
159
162
|
- features/span.feature
|
160
163
|
- features/step_definations/area_steps.rb
|
161
164
|
- features/step_definations/async_steps.rb
|
162
165
|
- features/step_definations/audio_steps.rb
|
166
|
+
- features/step_definations/bold_steps.rb
|
163
167
|
- features/step_definations/button_steps.rb
|
164
168
|
- features/step_definations/canvas_steps.rb
|
165
169
|
- features/step_definations/checkbox_steps.rb
|
@@ -183,7 +187,9 @@ files:
|
|
183
187
|
- features/step_definations/page_level_actions_steps.rb
|
184
188
|
- features/step_definations/page_traversal_steps.rb
|
185
189
|
- features/step_definations/paragraph_steps.rb
|
190
|
+
- features/step_definations/radio_button_group_steps.rb
|
186
191
|
- features/step_definations/radio_button_steps.rb
|
192
|
+
- features/step_definations/section_steps.rb
|
187
193
|
- features/step_definations/select_list_steps.rb
|
188
194
|
- features/step_definations/span_steps.rb
|
189
195
|
- features/step_definations/table_cell_steps.rb
|
@@ -214,6 +220,7 @@ files:
|
|
214
220
|
- lib/druid/elements.rb
|
215
221
|
- lib/druid/elements/area.rb
|
216
222
|
- lib/druid/elements/audio.rb
|
223
|
+
- lib/druid/elements/bold.rb
|
217
224
|
- lib/druid/elements/button.rb
|
218
225
|
- lib/druid/elements/canvas.rb
|
219
226
|
- lib/druid/elements/check_box.rb
|
@@ -241,6 +248,7 @@ files:
|
|
241
248
|
- lib/druid/elements/text_field.rb
|
242
249
|
- lib/druid/elements/unordered_list.rb
|
243
250
|
- lib/druid/elements/video.rb
|
251
|
+
- lib/druid/javascript/angularjs.rb
|
244
252
|
- lib/druid/javascript/jquery.rb
|
245
253
|
- lib/druid/javascript/prototype.rb
|
246
254
|
- lib/druid/javascript/yui.rb
|
@@ -249,11 +257,13 @@ files:
|
|
249
257
|
- lib/druid/nested_elements.rb
|
250
258
|
- lib/druid/page_factory.rb
|
251
259
|
- lib/druid/page_populator.rb
|
260
|
+
- lib/druid/sections.rb
|
252
261
|
- lib/druid/version.rb
|
253
262
|
- spec/druid/accessors_spec.rb
|
254
263
|
- spec/druid/druid_spec.rb
|
255
264
|
- spec/druid/element_locators_spec.rb
|
256
265
|
- spec/druid/elements/area_spec.rb
|
266
|
+
- spec/druid/elements/bold_spec.rb
|
257
267
|
- spec/druid/elements/button_spec.rb
|
258
268
|
- spec/druid/elements/canvas_spec.rb
|
259
269
|
- spec/druid/elements/check_box_spec.rb
|
@@ -284,6 +294,7 @@ files:
|
|
284
294
|
- spec/druid/nested_element_spec.rb
|
285
295
|
- spec/druid/page_factory_spec.rb
|
286
296
|
- spec/druid/page_populator_spec.rb
|
297
|
+
- spec/druid/page_section_spec.rb
|
287
298
|
- spec/spec_helper.rb
|
288
299
|
homepage: http://github.com/timsheng/druid
|
289
300
|
licenses:
|
@@ -313,6 +324,7 @@ test_files:
|
|
313
324
|
- features/area.feature
|
314
325
|
- features/async.feature
|
315
326
|
- features/audio.feature
|
327
|
+
- features/bold.feature
|
316
328
|
- features/button.feature
|
317
329
|
- features/canvas.feature
|
318
330
|
- features/checkbox.feature
|
@@ -361,6 +373,7 @@ test_files:
|
|
361
373
|
- features/page_level_actions.feature
|
362
374
|
- features/paragraph.feature
|
363
375
|
- features/radio_button.feature
|
376
|
+
- features/radio_button_group.feature
|
364
377
|
- features/sample-app/public/jquery-1.3.2.js
|
365
378
|
- features/sample-app/public/jquery.html
|
366
379
|
- features/sample-app/public/movie.mp4
|
@@ -368,11 +381,13 @@ test_files:
|
|
368
381
|
- features/sample-app/public/prototype-1.6.0.3.js
|
369
382
|
- features/sample-app/public/prototype.html
|
370
383
|
- features/sample-app/sample_app.rb
|
384
|
+
- features/section.feature
|
371
385
|
- features/select_list.feature
|
372
386
|
- features/span.feature
|
373
387
|
- features/step_definations/area_steps.rb
|
374
388
|
- features/step_definations/async_steps.rb
|
375
389
|
- features/step_definations/audio_steps.rb
|
390
|
+
- features/step_definations/bold_steps.rb
|
376
391
|
- features/step_definations/button_steps.rb
|
377
392
|
- features/step_definations/canvas_steps.rb
|
378
393
|
- features/step_definations/checkbox_steps.rb
|
@@ -396,7 +411,9 @@ test_files:
|
|
396
411
|
- features/step_definations/page_level_actions_steps.rb
|
397
412
|
- features/step_definations/page_traversal_steps.rb
|
398
413
|
- features/step_definations/paragraph_steps.rb
|
414
|
+
- features/step_definations/radio_button_group_steps.rb
|
399
415
|
- features/step_definations/radio_button_steps.rb
|
416
|
+
- features/step_definations/section_steps.rb
|
400
417
|
- features/step_definations/select_list_steps.rb
|
401
418
|
- features/step_definations/span_steps.rb
|
402
419
|
- features/step_definations/table_cell_steps.rb
|
@@ -423,6 +440,7 @@ test_files:
|
|
423
440
|
- spec/druid/druid_spec.rb
|
424
441
|
- spec/druid/element_locators_spec.rb
|
425
442
|
- spec/druid/elements/area_spec.rb
|
443
|
+
- spec/druid/elements/bold_spec.rb
|
426
444
|
- spec/druid/elements/button_spec.rb
|
427
445
|
- spec/druid/elements/canvas_spec.rb
|
428
446
|
- spec/druid/elements/check_box_spec.rb
|
@@ -453,4 +471,5 @@ test_files:
|
|
453
471
|
- spec/druid/nested_element_spec.rb
|
454
472
|
- spec/druid/page_factory_spec.rb
|
455
473
|
- spec/druid/page_populator_spec.rb
|
474
|
+
- spec/druid/page_section_spec.rb
|
456
475
|
- spec/spec_helper.rb
|