page-object 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +49 -0
- data/Guardfile +3 -3
- data/features/area.feature +34 -0
- data/features/html/planets.gif +0 -0
- data/features/html/static_elements.html +7 -0
- data/features/html/sun.gif +0 -0
- data/features/html/sun.html +7 -0
- data/features/step_definitions/area_steps.rb +19 -0
- data/features/step_definitions/element_steps.rb +4 -0
- data/features/support/page.rb +12 -2
- data/lib/page-object/accessors.rb +729 -0
- data/lib/page-object/element_locators.rb +30 -0
- data/lib/page-object/elements.rb +1 -0
- data/lib/page-object/elements/area.rb +31 -0
- data/lib/page-object/elements/element.rb +1 -1
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +23 -0
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +21 -1
- data/lib/page-object/version.rb +1 -1
- data/spec/page-object/elements/area_spec.rb +45 -0
- metadata +17 -4
@@ -881,6 +881,36 @@ module PageObject
|
|
881
881
|
platform.file_fields_for(identifier.clone)
|
882
882
|
end
|
883
883
|
|
884
|
+
#
|
885
|
+
# Finds an area
|
886
|
+
#
|
887
|
+
# @param [Hash] identifier how we find an area. You can use a multiple paramaters
|
888
|
+
# by combining of any of the following except xpath. It defaults to {:index => 0}
|
889
|
+
# which will return the first file field. The valid keys are:
|
890
|
+
# * :class => Watir and Selenium
|
891
|
+
# * :id => Watir and Selenium
|
892
|
+
# * :index => Watir and Selenium
|
893
|
+
# * :name => Watir and Selenium
|
894
|
+
# * :xpath => Watir and Selenium
|
895
|
+
def area_element(identifier={:index => 0})
|
896
|
+
platform.area_for(identifier.clone)
|
897
|
+
end
|
898
|
+
|
899
|
+
#
|
900
|
+
# Finds all areas that match the provided identifier
|
901
|
+
#
|
902
|
+
# @param [Hash] identifier how we find an area. You can use a multiple paramaters
|
903
|
+
# by combining of any of the following except xpath. It defaults to and empty Hash
|
904
|
+
# which will return all file fields. The valid keys are:
|
905
|
+
# * :class => Watir and Selenium
|
906
|
+
# * :id => Watir and Selenium
|
907
|
+
# * :index => Watir and Selenium
|
908
|
+
# * :name => Watir and Selenium
|
909
|
+
# * :xpath => Watir and Selenium
|
910
|
+
def area_elements(identifier={})
|
911
|
+
platform.areas_for(identifier.clone)
|
912
|
+
end
|
913
|
+
|
884
914
|
#
|
885
915
|
# Finds an element
|
886
916
|
#
|
data/lib/page-object/elements.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module PageObject
|
3
|
+
module Elements
|
4
|
+
class Area < Element
|
5
|
+
|
6
|
+
#
|
7
|
+
# return the coordinates of the area
|
8
|
+
#
|
9
|
+
def coords
|
10
|
+
attribute(:coords)
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# return the shape of the area
|
15
|
+
#
|
16
|
+
def shape
|
17
|
+
attribute(:shape)
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# return the href of the area
|
22
|
+
#
|
23
|
+
def href
|
24
|
+
attribute(:href)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
::PageObject::Elements.type_to_class[:area] = ::PageObject::Elements::Area
|
30
|
+
end
|
31
|
+
end
|
@@ -105,7 +105,7 @@ module PageObject
|
|
105
105
|
protected
|
106
106
|
|
107
107
|
def self.should_build_watir_xpath identifier
|
108
|
-
['table', 'span', 'div', 'td', 'li', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'label'].include? identifier[:tag_name] and identifier[:name]
|
108
|
+
['table', 'span', 'div', 'td', 'li', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'label', 'area'].include? identifier[:tag_name] and identifier[:name]
|
109
109
|
end
|
110
110
|
|
111
111
|
def self.build_xpath_for identifier
|
@@ -863,6 +863,29 @@ module PageObject
|
|
863
863
|
find_selenium_elements(identifier, Elements::FileField, 'input', :type => 'file')
|
864
864
|
end
|
865
865
|
|
866
|
+
#
|
867
|
+
# platform method to click on an area
|
868
|
+
#
|
869
|
+
def click_area_for(identifier)
|
870
|
+
process_selenium_call(identifier, Elements::Area, 'area') do |how, what|
|
871
|
+
@browser.find_element(how, what).click
|
872
|
+
end
|
873
|
+
end
|
874
|
+
|
875
|
+
#
|
876
|
+
# platform method to retrieve an area element
|
877
|
+
#
|
878
|
+
def area_for(identifier)
|
879
|
+
find_selenium_element(identifier, Elements::Area, 'area')
|
880
|
+
end
|
881
|
+
|
882
|
+
#
|
883
|
+
# platform method to return an array of area elements
|
884
|
+
#
|
885
|
+
def areas_for(identifier)
|
886
|
+
find_selenium_elements(identifier, Elements::Area, 'area')
|
887
|
+
end
|
888
|
+
|
866
889
|
#
|
867
890
|
# platform method to retrieve a generic element
|
868
891
|
# See PageObject::Accessors#element
|
@@ -804,7 +804,27 @@ module PageObject
|
|
804
804
|
#
|
805
805
|
def file_fields_for(identifier)
|
806
806
|
find_watir_elements("file_fields(identifier)", Elements::FileField, identifier)
|
807
|
-
|
807
|
+
end
|
808
|
+
|
809
|
+
#
|
810
|
+
# platform method to click on an area
|
811
|
+
#
|
812
|
+
def click_area_for(identifier)
|
813
|
+
process_watir_call("area(identifier).click", Elements::Area, identifier, nil, 'area')
|
814
|
+
end
|
815
|
+
|
816
|
+
#
|
817
|
+
# platform method to retrieve an area element
|
818
|
+
#
|
819
|
+
def area_for(identifier)
|
820
|
+
find_watir_element("area(identifier)", Elements::Area, identifier, 'area')
|
821
|
+
end
|
822
|
+
|
823
|
+
#
|
824
|
+
# platform method to retrieve an array of area elements
|
825
|
+
#
|
826
|
+
def areas_for(identifier)
|
827
|
+
find_watir_elements("areas(identifier)", Elements::Area, identifier, 'area')
|
808
828
|
end
|
809
829
|
|
810
830
|
#
|
data/lib/page-object/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'page-object/elements'
|
3
|
+
|
4
|
+
describe PageObject::Elements::Area do
|
5
|
+
let(:area) { PageObject::Elements::Area }
|
6
|
+
|
7
|
+
context "when mapping how to find an element" do
|
8
|
+
it "should map watir types to same" do
|
9
|
+
[:class, :id, :index, :name, :xpath].each do |t|
|
10
|
+
identifier = area.watir_identifier_for t => 'value'
|
11
|
+
identifier.keys.first.should == t
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should map selenium types to same" do
|
16
|
+
[:class, :id, :index, :name, :xpath].each do |t|
|
17
|
+
key, value = area.selenium_identifier_for t => 'value'
|
18
|
+
key.should == t
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "implementation" do
|
24
|
+
let(:area_element) { double('area_element') }
|
25
|
+
|
26
|
+
context "when using selenium" do
|
27
|
+
let(:selenium_area) { PageObject::Elements::Area.new(area_element, :platform => :selenium_webdriver) }
|
28
|
+
|
29
|
+
it "should know its coords" do
|
30
|
+
area_element.should_receive(:attribute).with(:coords).and_return("1,2,3,4")
|
31
|
+
selenium_area.coords.should == "1,2,3,4"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should know its shape" do
|
35
|
+
area_element.should_receive(:attribute).with(:shape).and_return('circle')
|
36
|
+
selenium_area.shape.should == 'circle'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should know its href" do
|
40
|
+
area_element.should_receive(:attribute).with(:href).and_return('twitter.com')
|
41
|
+
selenium_area.href.should == 'twitter.com'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
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.7.
|
4
|
+
version: 0.7.1
|
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-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- README.md
|
126
126
|
- Rakefile
|
127
127
|
- cucumber.yml
|
128
|
+
- features/area.feature
|
128
129
|
- features/async.feature
|
129
130
|
- features/button.feature
|
130
131
|
- features/check_box.feature
|
@@ -154,8 +155,11 @@ files:
|
|
154
155
|
- features/html/nested_frame_2.html
|
155
156
|
- features/html/nested_frame_3.html
|
156
157
|
- features/html/nested_frames.html
|
158
|
+
- features/html/planets.gif
|
157
159
|
- features/html/static_elements.html
|
158
160
|
- features/html/success.html
|
161
|
+
- features/html/sun.gif
|
162
|
+
- features/html/sun.html
|
159
163
|
- features/image.feature
|
160
164
|
- features/indexed_property.feature
|
161
165
|
- features/javascript.feature
|
@@ -177,6 +181,7 @@ files:
|
|
177
181
|
- features/select_list.feature
|
178
182
|
- features/span.feature
|
179
183
|
- features/step_definitions/accessor_steps.rb
|
184
|
+
- features/step_definitions/area_steps.rb
|
180
185
|
- features/step_definitions/async_steps.rb
|
181
186
|
- features/step_definitions/button_steps.rb
|
182
187
|
- features/step_definitions/check_box_steps.rb
|
@@ -225,6 +230,7 @@ files:
|
|
225
230
|
- lib/page-object/core_ext/string.rb
|
226
231
|
- lib/page-object/element_locators.rb
|
227
232
|
- lib/page-object/elements.rb
|
233
|
+
- lib/page-object/elements/area.rb
|
228
234
|
- lib/page-object/elements/button.rb
|
229
235
|
- lib/page-object/elements/check_box.rb
|
230
236
|
- lib/page-object/elements/div.rb
|
@@ -295,6 +301,7 @@ files:
|
|
295
301
|
- lib/page-object/version.rb
|
296
302
|
- page-object.gemspec
|
297
303
|
- spec/page-object/element_locators_spec.rb
|
304
|
+
- spec/page-object/elements/area_spec.rb
|
298
305
|
- spec/page-object/elements/button_spec.rb
|
299
306
|
- spec/page-object/elements/check_box_spec.rb
|
300
307
|
- spec/page-object/elements/div_spec.rb
|
@@ -347,7 +354,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
347
354
|
version: '0'
|
348
355
|
segments:
|
349
356
|
- 0
|
350
|
-
hash: -
|
357
|
+
hash: -3346417755984147094
|
351
358
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
352
359
|
none: false
|
353
360
|
requirements:
|
@@ -356,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
356
363
|
version: '0'
|
357
364
|
segments:
|
358
365
|
- 0
|
359
|
-
hash: -
|
366
|
+
hash: -3346417755984147094
|
360
367
|
requirements: []
|
361
368
|
rubyforge_project: page-object
|
362
369
|
rubygems_version: 1.8.24
|
@@ -364,6 +371,7 @@ signing_key:
|
|
364
371
|
specification_version: 3
|
365
372
|
summary: Page Object DSL for browser testing
|
366
373
|
test_files:
|
374
|
+
- features/area.feature
|
367
375
|
- features/async.feature
|
368
376
|
- features/button.feature
|
369
377
|
- features/check_box.feature
|
@@ -393,8 +401,11 @@ test_files:
|
|
393
401
|
- features/html/nested_frame_2.html
|
394
402
|
- features/html/nested_frame_3.html
|
395
403
|
- features/html/nested_frames.html
|
404
|
+
- features/html/planets.gif
|
396
405
|
- features/html/static_elements.html
|
397
406
|
- features/html/success.html
|
407
|
+
- features/html/sun.gif
|
408
|
+
- features/html/sun.html
|
398
409
|
- features/image.feature
|
399
410
|
- features/indexed_property.feature
|
400
411
|
- features/javascript.feature
|
@@ -416,6 +427,7 @@ test_files:
|
|
416
427
|
- features/select_list.feature
|
417
428
|
- features/span.feature
|
418
429
|
- features/step_definitions/accessor_steps.rb
|
430
|
+
- features/step_definitions/area_steps.rb
|
419
431
|
- features/step_definitions/async_steps.rb
|
420
432
|
- features/step_definitions/button_steps.rb
|
421
433
|
- features/step_definitions/check_box_steps.rb
|
@@ -460,6 +472,7 @@ test_files:
|
|
460
472
|
- features/text_field.feature
|
461
473
|
- features/unordered_list.feature
|
462
474
|
- spec/page-object/element_locators_spec.rb
|
475
|
+
- spec/page-object/elements/area_spec.rb
|
463
476
|
- spec/page-object/elements/button_spec.rb
|
464
477
|
- spec/page-object/elements/check_box_spec.rb
|
465
478
|
- spec/page-object/elements/div_spec.rb
|