page-object 0.7.6 → 0.8
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.
- data/ChangeLog +37 -0
- data/features/element.feature +2 -1
- data/features/gxt_table_extension.feature +24 -0
- data/features/multi_elements.feature +182 -0
- data/features/ordered_list.feature +5 -0
- data/features/step_definitions/element_steps.rb +7 -2
- data/features/step_definitions/gxt_table_steps.rb +40 -0
- data/features/step_definitions/multi_elements_steps.rb +111 -0
- data/features/step_definitions/ordered_list_steps.rb +4 -0
- data/features/step_definitions/table_steps.rb +4 -0
- data/features/step_definitions/unordered_list_steps.rb +5 -1
- data/features/table.feature +4 -0
- data/features/unordered_list.feature +5 -0
- data/lib/page-object.rb +16 -11
- data/lib/page-object/accessors.rb +71 -6
- data/lib/page-object/platforms/selenium_webdriver/element.rb +10 -0
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +30 -0
- data/lib/page-object/platforms/watir_webdriver/element.rb +9 -0
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +24 -0
- data/lib/page-object/version.rb +1 -1
- data/lib/page-object/widgets.rb +120 -0
- data/page-object.gemspec +2 -2
- data/spec/page-object/widget_spec.rb +194 -0
- metadata +15 -8
data/page-object.gemspec
CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency 'watir-webdriver', '>= 0.6.
|
23
|
-
s.add_dependency 'selenium-webdriver', '>= 2.
|
22
|
+
s.add_dependency 'watir-webdriver', '>= 0.6.2'
|
23
|
+
s.add_dependency 'selenium-webdriver', '>= 2.27.2'
|
24
24
|
|
25
25
|
s.add_development_dependency 'rspec', '>= 2.6.0'
|
26
26
|
s.add_development_dependency 'cucumber', '< 1.2.0'
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'page-object'
|
3
|
+
require 'page-object/elements'
|
4
|
+
|
5
|
+
describe "Widget PageObject Extensions" do
|
6
|
+
context "When module is loaded and included before PageObject is loaded " do
|
7
|
+
|
8
|
+
class GxtTable < PageObject::Elements::Table
|
9
|
+
|
10
|
+
@protected
|
11
|
+
|
12
|
+
def child_xpath
|
13
|
+
".//descendant::tr"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
PageObject.register_widget :gxt_table, GxtTable, :div
|
18
|
+
end
|
19
|
+
|
20
|
+
class WidgetTestPageObject
|
21
|
+
include PageObject
|
22
|
+
|
23
|
+
gxt_table(:a_table, :id => "top_div_id")
|
24
|
+
gxt_table :gxt_block_table do |element|
|
25
|
+
"block_gxt_table"
|
26
|
+
end
|
27
|
+
|
28
|
+
div(:outer_div)
|
29
|
+
gxt_table(:a_nested_gxt_table) { |page| page.outer_div_element.gxt_table_element }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "Widget Element Locators" do
|
33
|
+
|
34
|
+
context "when using Watir" do
|
35
|
+
let(:watir_browser) { mock_watir_browser }
|
36
|
+
let(:watir_page_object) { WidgetTestPageObject.new(watir_browser) }
|
37
|
+
|
38
|
+
it "should find a gxt_table element" do
|
39
|
+
watir_browser.should_receive(:div).with(:id => 'blah').and_return(watir_browser)
|
40
|
+
element = watir_page_object.gxt_table_element(:id => 'blah')
|
41
|
+
element.should be_instance_of GxtTable
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when using Selenium" do
|
46
|
+
let(:selenium_browser) { mock_selenium_browser }
|
47
|
+
let(:selenium_page_object) { WidgetTestPageObject.new(selenium_browser) }
|
48
|
+
|
49
|
+
it "should find a gxt_table element" do
|
50
|
+
selenium_browser.should_receive(:find_element).with(:id, 'blah').and_return(selenium_browser)
|
51
|
+
element = selenium_page_object.gxt_table_element(:id => 'blah')
|
52
|
+
element.should be_instance_of GxtTable
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "Widget Accessors" do
|
58
|
+
let(:watir_browser) { mock_watir_browser }
|
59
|
+
let(:watir_page_object) { WidgetTestPageObject.new(watir_browser) }
|
60
|
+
|
61
|
+
context "using default identifiers" do
|
62
|
+
class WatirDefaultIdentifier
|
63
|
+
include PageObject
|
64
|
+
|
65
|
+
gxt_table :default_gxt_table
|
66
|
+
end
|
67
|
+
|
68
|
+
let(:default_identifier) { WatirDefaultIdentifier.new(watir_browser) }
|
69
|
+
|
70
|
+
def mock_driver_for(tag)
|
71
|
+
watir_browser.should_receive(tag).with(:index => 0).and_return(watir_browser)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should work for a gxt_table" do
|
75
|
+
mock_driver_for :div
|
76
|
+
default_identifier.default_gxt_table_element.should_not be_nil
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "gxt_table accessors" do
|
82
|
+
context "when called on a page object" do
|
83
|
+
it "should generate accessor methods" do
|
84
|
+
watir_page_object.should respond_to(:a_table_element)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should call a block on the element method when present" do
|
88
|
+
watir_page_object.gxt_block_table_element.should == "block_gxt_table"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should retrieve the table element from the page" do
|
93
|
+
watir_browser.should_receive(:div).and_return(watir_browser)
|
94
|
+
element = watir_page_object.a_table_element
|
95
|
+
element.should be_instance_of GxtTable
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "Widget Elements-GxtTable" do
|
101
|
+
describe "when mapping how to find an element" do
|
102
|
+
it "should map watir types to same" do
|
103
|
+
[:class, :id, :index, :xpath].each do |t|
|
104
|
+
identifier = GxtTable.watir_identifier_for t => 'value'
|
105
|
+
identifier.keys.first.should == t
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should map selenium types to same" do
|
110
|
+
[:class, :id, :index, :name, :xpath].each do |t|
|
111
|
+
key, value = GxtTable.selenium_identifier_for t => 'value'
|
112
|
+
key.should == t
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "interface" do
|
118
|
+
let(:gxt_table_element) { double('gxt_table_element') }
|
119
|
+
|
120
|
+
before(:each) do
|
121
|
+
gxt_table_element.stub(:[]).and_return(gxt_table_element)
|
122
|
+
gxt_table_element.stub(:find_elements).and_return(gxt_table_element)
|
123
|
+
end
|
124
|
+
|
125
|
+
context "for watir" do
|
126
|
+
let(:watir_table) { GxtTable.new(gxt_table_element, :platform => :watir_webdriver) }
|
127
|
+
|
128
|
+
it "should return a table row when indexed" do
|
129
|
+
gxt_table_element.stub(:[]).with(1).and_return(gxt_table_element)
|
130
|
+
watir_table[1].should be_instance_of PageObject::Elements::TableRow
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should return the number of rows" do
|
134
|
+
gxt_table_element.stub(:wd).and_return(gxt_table_element)
|
135
|
+
gxt_table_element.should_receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
|
136
|
+
gxt_table_element.should_receive(:size).and_return(2)
|
137
|
+
watir_table.rows.should == 2
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "for selenium" do
|
142
|
+
let(:selenium_table) { GxtTable.new(gxt_table_element, :platform => :selenium_webdriver) }
|
143
|
+
|
144
|
+
it "should return a table row when indexed" do
|
145
|
+
gxt_table_element.should_receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
|
146
|
+
selenium_table[1].should be_instance_of PageObject::Elements::TableRow
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should return the number of rows" do
|
150
|
+
gxt_table_element.should_receive(:find_elements).with(:xpath, ".//descendant::tr").and_return(gxt_table_element)
|
151
|
+
gxt_table_element.should_receive(:size).and_return(2)
|
152
|
+
selenium_table.rows.should == 2
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should iterate over the table rows" do
|
156
|
+
selenium_table.should_receive(:rows).and_return(2)
|
157
|
+
count = 0
|
158
|
+
selenium_table.each { |e| count += 1 }
|
159
|
+
count.should == 2
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "Element with nested elements" do
|
166
|
+
context "in Watir" do
|
167
|
+
before(:each) do
|
168
|
+
@watir_driver = Watir::Element.new(nil, {})
|
169
|
+
@watir_element = PageObject::Elements::Element.new(@watir_driver, :platform => :watir_webdriver)
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should find a nested gxt_table" do
|
173
|
+
@watir_driver.should_receive(:div).and_return(@watir_driver)
|
174
|
+
@watir_element.gxt_table_element
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
context "in Selenium" do
|
179
|
+
before(:each) do
|
180
|
+
@selenium_driver = double('selenium')
|
181
|
+
@selenium_element = PageObject::Elements::Element.new(@selenium_driver, :platform => :selenium_webdriver)
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should find a nested gxt_table" do
|
185
|
+
@selenium_driver.should_receive(:find_element).and_return(@selenium_driver)
|
186
|
+
@selenium_element.gxt_table_element
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.8'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.6.
|
21
|
+
version: 0.6.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.6.
|
29
|
+
version: 0.6.2
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: selenium-webdriver
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.
|
37
|
+
version: 2.27.2
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
45
|
+
version: 2.27.2
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rspec
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- features/form.feature
|
138
138
|
- features/frames.feature
|
139
139
|
- features/generic_elements.feature
|
140
|
+
- features/gxt_table_extension.feature
|
140
141
|
- features/headings.feature
|
141
142
|
- features/hidden_field.feature
|
142
143
|
- features/html/async.html
|
@@ -202,6 +203,7 @@ files:
|
|
202
203
|
- features/step_definitions/form_steps.rb
|
203
204
|
- features/step_definitions/frames_steps.rb
|
204
205
|
- features/step_definitions/generic_element_steps.rb
|
206
|
+
- features/step_definitions/gxt_table_steps.rb
|
205
207
|
- features/step_definitions/headings_steps.rb
|
206
208
|
- features/step_definitions/hidden_field_steps.rb
|
207
209
|
- features/step_definitions/image_steps.rb
|
@@ -316,6 +318,7 @@ files:
|
|
316
318
|
- lib/page-object/platforms/watir_webdriver/text_field.rb
|
317
319
|
- lib/page-object/platforms/watir_webdriver/unordered_list.rb
|
318
320
|
- lib/page-object/version.rb
|
321
|
+
- lib/page-object/widgets.rb
|
319
322
|
- page-object.gemspec
|
320
323
|
- pageobject.gems
|
321
324
|
- spec/page-object/element_locators_spec.rb
|
@@ -358,6 +361,7 @@ files:
|
|
358
361
|
- spec/page-object/platforms/watir_webdriver_spec.rb
|
359
362
|
- spec/page-object/selenium_accessors_spec.rb
|
360
363
|
- spec/page-object/watir_accessors_spec.rb
|
364
|
+
- spec/page-object/widget_spec.rb
|
361
365
|
- spec/spec_helper.rb
|
362
366
|
homepage: http://github.com/cheezy/page-object
|
363
367
|
licenses: []
|
@@ -373,7 +377,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
373
377
|
version: '0'
|
374
378
|
segments:
|
375
379
|
- 0
|
376
|
-
hash:
|
380
|
+
hash: -1688683572184715777
|
377
381
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
378
382
|
none: false
|
379
383
|
requirements:
|
@@ -382,7 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
382
386
|
version: '0'
|
383
387
|
segments:
|
384
388
|
- 0
|
385
|
-
hash:
|
389
|
+
hash: -1688683572184715777
|
386
390
|
requirements: []
|
387
391
|
rubyforge_project: page-object
|
388
392
|
rubygems_version: 1.8.24
|
@@ -402,6 +406,7 @@ test_files:
|
|
402
406
|
- features/form.feature
|
403
407
|
- features/frames.feature
|
404
408
|
- features/generic_elements.feature
|
409
|
+
- features/gxt_table_extension.feature
|
405
410
|
- features/headings.feature
|
406
411
|
- features/hidden_field.feature
|
407
412
|
- features/html/async.html
|
@@ -467,6 +472,7 @@ test_files:
|
|
467
472
|
- features/step_definitions/form_steps.rb
|
468
473
|
- features/step_definitions/frames_steps.rb
|
469
474
|
- features/step_definitions/generic_element_steps.rb
|
475
|
+
- features/step_definitions/gxt_table_steps.rb
|
470
476
|
- features/step_definitions/headings_steps.rb
|
471
477
|
- features/step_definitions/hidden_field_steps.rb
|
472
478
|
- features/step_definitions/image_steps.rb
|
@@ -543,5 +549,6 @@ test_files:
|
|
543
549
|
- spec/page-object/platforms/watir_webdriver_spec.rb
|
544
550
|
- spec/page-object/selenium_accessors_spec.rb
|
545
551
|
- spec/page-object/watir_accessors_spec.rb
|
552
|
+
- spec/page-object/widget_spec.rb
|
546
553
|
- spec/spec_helper.rb
|
547
554
|
has_rdoc:
|