page-object 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +9 -0
- data/Guardfile +1 -1
- data/README.md +2 -0
- data/cucumber.yml +1 -1
- data/features/audio.feature +50 -0
- data/features/canvas.feature +36 -0
- data/features/html/static_elements.html +35 -0
- data/features/list_item.feature +1 -0
- data/features/step_definitions/audio_steps.rb +27 -0
- data/features/step_definitions/canvas_steps.rb +15 -0
- data/features/step_definitions/element_steps.rb +12 -0
- data/features/support/page.rb +18 -0
- data/features/table.feature +8 -0
- data/lib/page-object/accessors.rb +59 -0
- data/lib/page-object/element_locators.rb +60 -0
- data/lib/page-object/elements.rb +3 -0
- data/lib/page-object/elements/audio.rb +31 -0
- data/lib/page-object/elements/canvas.rb +23 -0
- data/lib/page-object/elements/element.rb +1 -1
- data/lib/page-object/elements/list_item.rb +9 -0
- data/lib/page-object/nested_elements.rb +24 -0
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +29 -1
- data/lib/page-object/platforms/selenium_webdriver/table_row.rb +2 -1
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +28 -0
- data/lib/page-object/platforms/watir_webdriver/table_row.rb +1 -0
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +1 -1
- data/spec/page-object/element_locators_spec.rb +132 -0
- data/spec/page-object/elements/canvas_spec.rb +40 -0
- data/spec/page-object/elements/list_item_spec.rb +2 -2
- data/spec/page-object/selenium_accessors_spec.rb +62 -1
- data/spec/page-object/watir_accessors_spec.rb +61 -0
- metadata +18 -6
data/ChangeLog
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== Version 0.7.2 / 2012-8-1
|
2
|
+
* Enhancements
|
3
|
+
* Added ability to find list_item by :text
|
4
|
+
* Added support for the following new elements
|
5
|
+
Canvas
|
6
|
+
Audio
|
7
|
+
* Updated to use selenium-webdriver 2.25.0
|
8
|
+
* Updated to provide better support for table_row.find_index_by_title when tables have theads... (George Shakhnazaryan)
|
9
|
+
|
1
10
|
=== Version 0.7.1 / 2012-7-15
|
2
11
|
* Enhancements
|
3
12
|
* Added support for the following new elements
|
data/Guardfile
CHANGED
@@ -11,7 +11,7 @@ guard 'rspec', :cli => '--color --format Fuubar' do
|
|
11
11
|
watch('spec/spec_helper.rb') { "spec" }
|
12
12
|
end
|
13
13
|
|
14
|
-
guard 'cucumber', :notification => true, :all_after_pass => false, :
|
14
|
+
guard 'cucumber', :notification => true, :all_after_pass => false, :cli => '--profile focus' do
|
15
15
|
watch(%r{^features/.+\.feature$})
|
16
16
|
watch(%r{^features/support/.+$}) { "features" }
|
17
17
|
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
data/README.md
CHANGED
@@ -15,6 +15,8 @@ To see the changes from release to release please look at the [ChangeLog](https:
|
|
15
15
|
|
16
16
|
To read about the motivation for this gem please read this [blog entry](http://www.cheezyworld.com/2010/11/19/ui-tests-introducing-a-simple-dsl/)
|
17
17
|
|
18
|
+
There is a book that describes in detail how to use this gem and others to create a complete view of testing web and other types of applications. The book is named [Cucumber & Cheese](http://leanpub.com/cucumber_and_cheese)
|
19
|
+
|
18
20
|
## Support
|
19
21
|
|
20
22
|
If you need help using the page-object gem please ask your questions on [Stack Overflow](http://stackoverflow.com). Please be sure to use the [page-object-gem](http://stackoverflow.com/questions/tagged/page-object-gem) tag. If you wish to report an issue or request a new feature use the [github issue tracking page](http://github.com/cheezy/page-object/issues).
|
data/cucumber.yml
CHANGED
@@ -5,5 +5,5 @@ std_opts = "--no-source --color --format Cucumber::Formatter::Fuubar"
|
|
5
5
|
default: DRIVER=WATIR <%= std_opts %> --tags ~@selenium_only
|
6
6
|
watir: DRIVER=WATIR <%= std_opts %> --tags ~@selenium_only
|
7
7
|
selenium: DRIVER=SELENIUM <%= std_opts %> --tags ~@watir_only
|
8
|
-
focus: DRIVER=
|
8
|
+
focus: DRIVER=WATIR <%= std_opts %> --tags ~@selenium_only --tags @focus
|
9
9
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Feature: Support for the audio element
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I am on the static elements page
|
5
|
+
|
6
|
+
Scenario: finding an audio element
|
7
|
+
When I retrieve the audio element
|
8
|
+
Then I should know it exists
|
9
|
+
And I should know it is visible
|
10
|
+
|
11
|
+
Scenario Outline: Locating an audio element on the page
|
12
|
+
When I search for the audio element by "<search_by>"
|
13
|
+
Then I should know it is visible
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
| search_by |
|
17
|
+
| id |
|
18
|
+
| class |
|
19
|
+
| name |
|
20
|
+
| xpath |
|
21
|
+
| index |
|
22
|
+
|
23
|
+
Scenario Outline: Locating audios using multiple parameters
|
24
|
+
When I search for the audio element by "<param1>" and "<param2>"
|
25
|
+
Then I should know it is visible
|
26
|
+
|
27
|
+
Examples:
|
28
|
+
| param1 | param2 |
|
29
|
+
| class | index |
|
30
|
+
| name | index |
|
31
|
+
|
32
|
+
Scenario: Should know if it is autoplay
|
33
|
+
When I retrieve the audio element
|
34
|
+
Then I should know the audio is not autoplay
|
35
|
+
|
36
|
+
Scenario: Should know if the controls are displayed
|
37
|
+
When I retrieve the audio element
|
38
|
+
Then I should know that the controls are displayed
|
39
|
+
|
40
|
+
Scenario: Should know if it is paused
|
41
|
+
When I retrieve the audio element
|
42
|
+
Then I should know that the audio is paused
|
43
|
+
|
44
|
+
Scenario: Should know its duration
|
45
|
+
When I retrieve the audio element
|
46
|
+
Then I should know that the duration is greater than 74 seconds
|
47
|
+
|
48
|
+
Scenario: Should know its volume
|
49
|
+
When I retrieve the audio element
|
50
|
+
Then I should know that its volume is 1
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: Support for the canvas element
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I am on the static elements page
|
5
|
+
|
6
|
+
Scenario: Retrieve a canvas element
|
7
|
+
When I retrieve the canvas element
|
8
|
+
Then I should know it exists
|
9
|
+
And I should know it is visible
|
10
|
+
|
11
|
+
Scenario Outline: Locating a canvas on the page
|
12
|
+
When I search for the canvas by "<search_by>"
|
13
|
+
Then I should know it is visible
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
| search_by |
|
17
|
+
| id |
|
18
|
+
| class |
|
19
|
+
| name |
|
20
|
+
| xpath |
|
21
|
+
| index |
|
22
|
+
|
23
|
+
Scenario: Determining the width and height of the canvas
|
24
|
+
When I retrieve the canvas element
|
25
|
+
Then I should see that the canvas width is "200"
|
26
|
+
And I should see that the canvas height is "100"
|
27
|
+
|
28
|
+
Scenario Outline: Locating canvases using multiple parameters
|
29
|
+
When I search for the canvas element by "<param1>" and "<param2>"
|
30
|
+
Then I should know it is visible
|
31
|
+
|
32
|
+
Scenarios:
|
33
|
+
| param1 | param2 |
|
34
|
+
| class | index |
|
35
|
+
| name | index |
|
36
|
+
|
@@ -31,6 +31,22 @@
|
|
31
31
|
<area shape="circle" coords="90,58,3" href="mercur.html"/>
|
32
32
|
<area shape="circle" coords="124,58,8" href="venus.html"/>
|
33
33
|
</map>
|
34
|
+
|
35
|
+
<canvas id="canvas" name="canvas" class="canvas" width="200" height="100"></canvas>
|
36
|
+
<script type="text/javascript">
|
37
|
+
var c=document.getElementById("myCanvas");
|
38
|
+
var ctx=c.getContext("2d");
|
39
|
+
ctx.fillStyle="#FF0000";
|
40
|
+
ctx.fillRect(0,0,150,75);
|
41
|
+
</script>
|
42
|
+
|
43
|
+
<audio controls id="audio" name="audio" class="audio">
|
44
|
+
<source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.mp4"
|
45
|
+
type='audio/mp4'>
|
46
|
+
<source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.oga"
|
47
|
+
type='audio/ogg; codecs=vorbis'>
|
48
|
+
<p>Your user agent does not support the HTML5 Audio element.</p>
|
49
|
+
</audio>
|
34
50
|
|
35
51
|
<a href="success.html" id="link_id" name="link_name" class="link_class" title="link_title">Google Search</a>
|
36
52
|
|
@@ -62,6 +78,25 @@
|
|
62
78
|
</tr>
|
63
79
|
</table>
|
64
80
|
|
81
|
+
<table id='table_with_thead_id' border='1'>
|
82
|
+
<thead>
|
83
|
+
<tr>
|
84
|
+
<th>Col1</th>
|
85
|
+
<th>Col2</th>
|
86
|
+
</tr>
|
87
|
+
</thead>
|
88
|
+
<tbody>
|
89
|
+
<tr>
|
90
|
+
<td>Data1</td>
|
91
|
+
<td>Data2</td>
|
92
|
+
</tr>
|
93
|
+
<tr>
|
94
|
+
<td>Data3</td>
|
95
|
+
<td>Data4</td>
|
96
|
+
</tr>
|
97
|
+
</tbody>
|
98
|
+
</table>
|
99
|
+
|
65
100
|
<form method="get" action="success.html">
|
66
101
|
<input id='button_id' name='button_name' class='button_class' type="submit" value="Click Me"/>
|
67
102
|
<input id='button_image_id' type='image' src='images/submit.gif' alt='Submit'/>
|
data/features/list_item.feature
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
When /^I search for the audio element by "([^\"]*)"$/ do |how|
|
2
|
+
@element = @page.send "audio_#{how}_element"
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I search for the audio element by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
6
|
+
@element = @page.send "audio_#{param1}_#{param2}_element"
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I should know the audio is not autoplay$/ do
|
10
|
+
@element.should_not be_autoplay
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^I should know that the controls are displayed$/ do
|
14
|
+
@element.should have_controls
|
15
|
+
end
|
16
|
+
|
17
|
+
Then /^I should know that the audio is paused$/ do
|
18
|
+
@element.should be_paused
|
19
|
+
end
|
20
|
+
|
21
|
+
Then /^I should know that the duration is greater than (\d+) seconds$/ do |duration|
|
22
|
+
@element.duration.should > duration.to_f
|
23
|
+
end
|
24
|
+
|
25
|
+
Then /^I should know that its volume is (\d+)$/ do |volume|
|
26
|
+
@element.volume.should == volume.to_i
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
When /^I search for the canvas by "([^\"]*)"$/ do |how|
|
2
|
+
@element = @page.send "canvas_#{how}_element"
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I should see that the canvas width is "([^\"]*)"$/ do |width|
|
6
|
+
@element.width.should == width.to_i
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I should see that the canvas height is "([^\"]*)"$/ do |height|
|
10
|
+
@element.height.should == height.to_i
|
11
|
+
end
|
12
|
+
|
13
|
+
When /^I search for the canvas element by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
|
14
|
+
@element = @page.send "canvas_#{param1}_#{param2}_element"
|
15
|
+
end
|
@@ -30,6 +30,10 @@ When /^I retrieve a table element$/ do
|
|
30
30
|
@element = @page.table_id_element
|
31
31
|
end
|
32
32
|
|
33
|
+
When /^I retrieve a table with thead element$/ do
|
34
|
+
@element = @page.table_with_thead_id_element
|
35
|
+
end
|
36
|
+
|
33
37
|
When /^I retrieve a button element$/ do
|
34
38
|
@element = @page.button_id_element
|
35
39
|
end
|
@@ -46,6 +50,14 @@ When /^I retrieve the area element$/ do
|
|
46
50
|
@element = @page.area_id_element
|
47
51
|
end
|
48
52
|
|
53
|
+
When /^I retrieve the canvas element$/ do
|
54
|
+
@element = @page.canvas_id_element
|
55
|
+
end
|
56
|
+
|
57
|
+
When /^I retrieve the audio element$/ do
|
58
|
+
@element = @page.audio_id_element
|
59
|
+
end
|
60
|
+
|
49
61
|
When /^I locate the form$/ do
|
50
62
|
@element = @page.form_id_element
|
51
63
|
end
|
data/features/support/page.rb
CHANGED
@@ -116,6 +116,7 @@ class Page
|
|
116
116
|
table(:table_xpath, :xpath => '//table')
|
117
117
|
table(:table_class_index, :class => "table_class", :index => 0)
|
118
118
|
table(:table_name_index, :name => "table_name", :index => 0)
|
119
|
+
table(:table_with_thead_id, :id => 'table_with_thead_id')
|
119
120
|
|
120
121
|
cell(:cell_id, :id => 'cell_id')
|
121
122
|
cell(:cell_name, :name => 'cell_name')
|
@@ -176,6 +177,7 @@ class Page
|
|
176
177
|
list_item(:li_name, :name => 'li_name')
|
177
178
|
list_item(:li_class, :class => 'li_class')
|
178
179
|
list_item(:li_index, :index => 0)
|
180
|
+
list_item(:li_text, :text => 'Item One')
|
179
181
|
list_item(:li_xpath, :xpath => '//li[1]')
|
180
182
|
list_item(:li_class_index, :class => "li_class", :index => 0)
|
181
183
|
list_item(:li_name_index, :name => "li_name", :index => 0)
|
@@ -285,6 +287,22 @@ class Page
|
|
285
287
|
area(:area_class_index, :class => 'area', :index => 0)
|
286
288
|
area(:area_name_index, :name => 'area', :index => 0)
|
287
289
|
|
290
|
+
canvas(:canvas_id, :id => 'canvas')
|
291
|
+
canvas(:canvas_name, :name => 'canvas')
|
292
|
+
canvas(:canvas_class, :class => 'canvas')
|
293
|
+
canvas(:canvas_index, :index => 0)
|
294
|
+
canvas(:canvas_xpath, :xpath => '//canvas')
|
295
|
+
canvas(:canvas_class_index, :class => 'canvas', :index => 0)
|
296
|
+
canvas(:canvas_name_index, :name => 'canvas', :index => 0)
|
297
|
+
|
298
|
+
audio(:audio_id, :id => 'audio')
|
299
|
+
audio(:audio_name, :name => 'audio')
|
300
|
+
audio(:audio_class, :class => 'audio')
|
301
|
+
audio(:audio_index, :index => 0)
|
302
|
+
audio(:audio_xpath, :xpath => '//audio')
|
303
|
+
audio(:audio_class_index, :class => 'audio', :index => 0)
|
304
|
+
audio(:audio_name_index, :name => 'audio', :index => 0)
|
305
|
+
|
288
306
|
element(:article_id, :article, :id => 'article_id')
|
289
307
|
element(:header_id, :header, :id => 'header_id')
|
290
308
|
element(:footer_id, :footer, :id => 'footer_id')
|
data/features/table.feature
CHANGED
@@ -46,6 +46,14 @@ Feature: Table
|
|
46
46
|
When I retrieve a table element
|
47
47
|
Then the data for column "Data2" and row "2" should be "Data4"
|
48
48
|
|
49
|
+
Scenario: Retrieve data from a table with a thead using a column header
|
50
|
+
When I retrieve a table with thead element
|
51
|
+
Then the data for column "Col1" and row "2" should be "Data1"
|
52
|
+
|
53
|
+
Scenario: Retrieve data from the first row of a table with a thead using a column header
|
54
|
+
When I retrieve a table with thead element
|
55
|
+
Then the data for column "Col1" and row "1" should be "Col1"
|
56
|
+
|
49
57
|
Scenario: Retrieve data from a table using a partial column header
|
50
58
|
When I retrieve a table element
|
51
59
|
Then the data for column "ata2" and row "2" should be "Data4"
|
@@ -643,6 +643,7 @@ module PageObject
|
|
643
643
|
# * :id => Watir and Selenium
|
644
644
|
# * :index => Watir and Selenium
|
645
645
|
# * :name => Watir and Selenium
|
646
|
+
# * :text => Watir and Selenium
|
646
647
|
# * :xpath => Watir and Selenium
|
647
648
|
# @param optional block to be invoked when element method is called
|
648
649
|
#
|
@@ -1067,6 +1068,64 @@ module PageObject
|
|
1067
1068
|
end
|
1068
1069
|
end
|
1069
1070
|
|
1071
|
+
#
|
1072
|
+
# adds two methods - one to return the canvas element and another to check
|
1073
|
+
# the canvas's existence.
|
1074
|
+
#
|
1075
|
+
# @example
|
1076
|
+
# canvas(:my_canvas, :id => 'canvas_id')
|
1077
|
+
# # will generate 'my_canvas_element' and 'my_canvas?' methods
|
1078
|
+
#
|
1079
|
+
# @param [Symbol] the name used for the generated methods
|
1080
|
+
# @param [Hash] identifier how we find a canvas. You can use a multiple paramaters
|
1081
|
+
# by combining of any of the following except xpath. The valid keys are:
|
1082
|
+
# * :class => Watir and Selenium
|
1083
|
+
# * :id => Watir and Selenium
|
1084
|
+
# * :index => Watir and Selenium
|
1085
|
+
# * :name => Watir and Selenium
|
1086
|
+
# * :xpath => Watir and Selenium
|
1087
|
+
# @param optional block to be invoked when element method is called
|
1088
|
+
#
|
1089
|
+
def canvas(name, identifier={:index => 0}, &block)
|
1090
|
+
define_method("#{name}_element") do
|
1091
|
+
return call_block(&block) if block_given?
|
1092
|
+
platform.canvas_for(identifier.clone)
|
1093
|
+
end
|
1094
|
+
define_method("#{name}?") do
|
1095
|
+
return call_block(&block).exists? if block_given?
|
1096
|
+
platform.canvas_for(identifier.clone).exists?
|
1097
|
+
end
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
#
|
1101
|
+
# adds two methods - one to return the audio element and another to check
|
1102
|
+
# the audio's existence.
|
1103
|
+
#
|
1104
|
+
# @example
|
1105
|
+
# audio(:acdc, :id => 'audio_id')
|
1106
|
+
# # will generate 'acdc_element' and 'acdc?' methods
|
1107
|
+
#
|
1108
|
+
# @param [Symbol] the name used for the generated methods
|
1109
|
+
# @param [Hash] identifier how we find an audio element. You can use a multiple paramaters
|
1110
|
+
# by combining of any of the following except xpath. The valid keys are:
|
1111
|
+
# * :class => Watir and Selenium
|
1112
|
+
# * :id => Watir and Selenium
|
1113
|
+
# * :index => Watir and Selenium
|
1114
|
+
# * :name => Watir and Selenium
|
1115
|
+
# * :xpath => Watir and Selenium
|
1116
|
+
# @param optional block to be invoked when element method is called
|
1117
|
+
#
|
1118
|
+
def audio(name, identifier={:index => 0}, &block)
|
1119
|
+
define_method("#{name}_element") do
|
1120
|
+
return call_block(&block) if block_given?
|
1121
|
+
platform.audio_for(identifier.clone)
|
1122
|
+
end
|
1123
|
+
define_method("#{name}?") do
|
1124
|
+
return call_block(&block).exists? if block_given?
|
1125
|
+
platform.audio_for(identifier.clone).exists?
|
1126
|
+
end
|
1127
|
+
end
|
1128
|
+
|
1070
1129
|
#
|
1071
1130
|
# adds three methods - one to retrieve the text of an element, another
|
1072
1131
|
# to retrieve an element, and another to check the element's existence.
|
@@ -911,6 +911,66 @@ module PageObject
|
|
911
911
|
platform.areas_for(identifier.clone)
|
912
912
|
end
|
913
913
|
|
914
|
+
#
|
915
|
+
# Finds a canvas
|
916
|
+
#
|
917
|
+
# @param [Hash] identifier how we find a canvas. You can use a multiple paramaters
|
918
|
+
# by combining of any of the following except xpath. It defaults to {:index => 0}
|
919
|
+
# which will return the first file field. The valid keys are:
|
920
|
+
# * :class => Watir and Selenium
|
921
|
+
# * :id => Watir and Selenium
|
922
|
+
# * :index => Watir and Selenium
|
923
|
+
# * :name => Watir and Selenium
|
924
|
+
# * :xpath => Watir and Selenium
|
925
|
+
def canvas_element(identifier={:index => 0})
|
926
|
+
platform.canvas_for(identifier.clone)
|
927
|
+
end
|
928
|
+
|
929
|
+
#
|
930
|
+
# Finds all canvases that match the provided identifier
|
931
|
+
#
|
932
|
+
# @param [Hash] identifier how we find a canvas. You can use a multiple paramaters
|
933
|
+
# by combining of any of the following except xpath. It defaults to and empty Hash
|
934
|
+
# which will return all file fields. The valid keys are:
|
935
|
+
# * :class => Watir and Selenium
|
936
|
+
# * :id => Watir and Selenium
|
937
|
+
# * :index => Watir and Selenium
|
938
|
+
# * :name => Watir and Selenium
|
939
|
+
# * :xpath => Watir and Selenium
|
940
|
+
def canvas_elements(identifier={})
|
941
|
+
platform.canvases_for(identifier.clone)
|
942
|
+
end
|
943
|
+
|
944
|
+
#
|
945
|
+
# Finds an audio element
|
946
|
+
#
|
947
|
+
# @param [Hash] identifier how we find an audio. You can use a multiple paramaters
|
948
|
+
# by combining of any of the following except xpath. It defaults to {:index => 0}
|
949
|
+
# which will return the first file field. The valid keys are:
|
950
|
+
# * :class => Watir and Selenium
|
951
|
+
# * :id => Watir and Selenium
|
952
|
+
# * :index => Watir and Selenium
|
953
|
+
# * :name => Watir and Selenium
|
954
|
+
# * :xpath => Watir and Selenium
|
955
|
+
def audio_element(identifier={:index => 0})
|
956
|
+
platform.audio_for(identifier.clone)
|
957
|
+
end
|
958
|
+
|
959
|
+
#
|
960
|
+
# Finds all audio elements that match the provided identifier
|
961
|
+
#
|
962
|
+
# @param [Hash] identifier how we find an audio element. You can use a multiple paramaters
|
963
|
+
# by combining of any of the following except xpath. It defaults to and empty Hash
|
964
|
+
# which will return all file fields. The valid keys are:
|
965
|
+
# * :class => Watir and Selenium
|
966
|
+
# * :id => Watir and Selenium
|
967
|
+
# * :index => Watir and Selenium
|
968
|
+
# * :name => Watir and Selenium
|
969
|
+
# * :xpath => Watir and Selenium
|
970
|
+
def audio_elements(identifier={})
|
971
|
+
platform.audios_for(identifier.clone)
|
972
|
+
end
|
973
|
+
|
914
974
|
#
|
915
975
|
# Finds an element
|
916
976
|
#
|
data/lib/page-object/elements.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
module PageObject
|
3
|
+
module Elements
|
4
|
+
class Audio < Element
|
5
|
+
|
6
|
+
def autoplay?
|
7
|
+
attribute(:autoplay)
|
8
|
+
end
|
9
|
+
|
10
|
+
def has_controls?
|
11
|
+
attribute(:controls)
|
12
|
+
end
|
13
|
+
|
14
|
+
def paused?
|
15
|
+
attribute(:paused)
|
16
|
+
end
|
17
|
+
|
18
|
+
def duration
|
19
|
+
duration = attribute(:duration)
|
20
|
+
return duration.to_f if duration
|
21
|
+
end
|
22
|
+
|
23
|
+
def volume
|
24
|
+
volume = attribute(:volume)
|
25
|
+
return volume.to_i if volume
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
::PageObject::Elements.type_to_class[:audio] = ::PageObject::Elements::Audio
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module PageObject
|
3
|
+
module Elements
|
4
|
+
class Canvas < Element
|
5
|
+
#
|
6
|
+
# return the width of the canvas
|
7
|
+
#
|
8
|
+
def width
|
9
|
+
attribute(:width).to_i
|
10
|
+
end
|
11
|
+
|
12
|
+
#
|
13
|
+
# return the height of the canvas
|
14
|
+
#
|
15
|
+
def height
|
16
|
+
attribute(:height).to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
::PageObject::Elements.type_to_class[:canvas] = ::PageObject::Elements::Canvas
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -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', 'area'].include? identifier[:tag_name] and identifier[:name]
|
108
|
+
['table', 'span', 'div', 'td', 'li', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'label', 'area', 'canvas', 'audio'].include? identifier[:tag_name] and identifier[:name]
|
109
109
|
end
|
110
110
|
|
111
111
|
def self.build_xpath_for identifier
|
@@ -2,6 +2,15 @@ module PageObject
|
|
2
2
|
module Elements
|
3
3
|
class ListItem < Element
|
4
4
|
|
5
|
+
protected
|
6
|
+
|
7
|
+
def self.watir_finders
|
8
|
+
super + [:text]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.selenium_finders
|
12
|
+
super + [:text]
|
13
|
+
end
|
5
14
|
end
|
6
15
|
|
7
16
|
::PageObject::Elements.tag_to_class[:li] = ::PageObject::Elements::ListItem
|
@@ -204,5 +204,29 @@ module PageObject
|
|
204
204
|
def file_field_element(identifier={:index => 0})
|
205
205
|
@platform.file_field_for(identifier)
|
206
206
|
end
|
207
|
+
|
208
|
+
def area_element(identifier={:index => 0})
|
209
|
+
@platform.area_for(identifier)
|
210
|
+
end
|
211
|
+
|
212
|
+
def area_elements(identifier={:index => 0})
|
213
|
+
@platform.areas_for(identifier)
|
214
|
+
end
|
215
|
+
|
216
|
+
def canvas_element(identifier={:index => 0})
|
217
|
+
@platform.canvas_for(identifier)
|
218
|
+
end
|
219
|
+
|
220
|
+
def canvas_elements(identifier={:index => 0})
|
221
|
+
@platform.canvases_for(identifier)
|
222
|
+
end
|
223
|
+
|
224
|
+
def audio_element(identifier={:index => 0})
|
225
|
+
@platform.audio_for(identifier)
|
226
|
+
end
|
227
|
+
|
228
|
+
def audio_elements(identifier={:index => 0})
|
229
|
+
@platform.audios_for(identifier)
|
230
|
+
end
|
207
231
|
end
|
208
232
|
end
|
@@ -885,6 +885,34 @@ module PageObject
|
|
885
885
|
def areas_for(identifier)
|
886
886
|
find_selenium_elements(identifier, Elements::Area, 'area')
|
887
887
|
end
|
888
|
+
|
889
|
+
#
|
890
|
+
# platform method to retrieve a canvas element
|
891
|
+
#
|
892
|
+
def canvas_for(identifier)
|
893
|
+
find_selenium_element(identifier, Elements::Canvas, 'canvas')
|
894
|
+
end
|
895
|
+
|
896
|
+
#
|
897
|
+
# platform method to return an array of canvas elements
|
898
|
+
#
|
899
|
+
def canvases_for(identifier)
|
900
|
+
find_selenium_elements(identifier, Elements::Canvas, 'canvas')
|
901
|
+
end
|
902
|
+
|
903
|
+
#
|
904
|
+
# platform method to retrieve an audio element
|
905
|
+
#
|
906
|
+
def audio_for(identifier)
|
907
|
+
find_selenium_element(identifier, Elements::Audio, 'audio')
|
908
|
+
end
|
909
|
+
|
910
|
+
#
|
911
|
+
# platform method to return an array of audio elements
|
912
|
+
#
|
913
|
+
def audios_for(identifier)
|
914
|
+
find_selenium_elements(identifier, Elements::Audio, 'audio')
|
915
|
+
end
|
888
916
|
|
889
917
|
#
|
890
918
|
# platform method to retrieve a generic element
|
@@ -975,7 +1003,7 @@ module PageObject
|
|
975
1003
|
return false if identifier[:label]
|
976
1004
|
return false if identifier[:text] and tag == 'input' and additional[:type] == 'hidden'
|
977
1005
|
return false if identifier[:text] and tag == 'input' and additional[:type] == 'text'
|
978
|
-
return false if identifier[:text] and ['div', 'span', 'td', 'label'].include? tag
|
1006
|
+
return false if identifier[:text] and ['div', 'span', 'td', 'label', 'li'].include? tag
|
979
1007
|
return false if identifier[:title] and tag == 'input' and additional[:type] == 'text'
|
980
1008
|
return false if identifier[:title] and tag == 'input' and additional[:type] == 'file'
|
981
1009
|
return false if identifier[:title] and tag == 'a'
|
@@ -28,7 +28,8 @@ module PageObject
|
|
28
28
|
|
29
29
|
def find_index_by_title(title)
|
30
30
|
table = parent
|
31
|
-
|
31
|
+
parent_tag_name = parent.element.tag_name
|
32
|
+
table = table.parent if (parent_tag_name == 'tbody' || parent_tag_name == 'thead')
|
32
33
|
table[0].find_index { |column| column.text.include? title }
|
33
34
|
end
|
34
35
|
|
@@ -827,6 +827,34 @@ module PageObject
|
|
827
827
|
find_watir_elements("areas(identifier)", Elements::Area, identifier, 'area')
|
828
828
|
end
|
829
829
|
|
830
|
+
#
|
831
|
+
# platform method to retrieve a canvas element
|
832
|
+
#
|
833
|
+
def canvas_for(identifier)
|
834
|
+
find_watir_element("canvas(identifier)", Elements::Canvas, identifier, 'canvas')
|
835
|
+
end
|
836
|
+
|
837
|
+
#
|
838
|
+
# platform method to retrieve an array of canvas elements
|
839
|
+
#
|
840
|
+
def canvases_for(identifier)
|
841
|
+
find_watir_elements("canvases(identifier)", Elements::Canvas, identifier, 'canvas')
|
842
|
+
end
|
843
|
+
|
844
|
+
#
|
845
|
+
# platform method to retrieve an audio element
|
846
|
+
#
|
847
|
+
def audio_for(identifier)
|
848
|
+
find_watir_element("audio(identifier)", Elements::Audio, identifier, 'audio')
|
849
|
+
end
|
850
|
+
|
851
|
+
#
|
852
|
+
# platform method to retrieve an array of audio elements
|
853
|
+
#
|
854
|
+
def audios_for(identifier)
|
855
|
+
find_watir_elements("audios(identifier)", Elements::Audio, identifier, 'audio')
|
856
|
+
end
|
857
|
+
|
830
858
|
#
|
831
859
|
# platform method to return a PageObject::Elements::Element element
|
832
860
|
# See PageObject::Accessors#elem
|
data/lib/page-object/version.rb
CHANGED
data/page-object.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
s.add_dependency 'watir-webdriver', '>= 0.6.1'
|
23
|
-
s.add_dependency 'selenium-webdriver', '>= 2.
|
23
|
+
s.add_dependency 'selenium-webdriver', '>= 2.25.0'
|
24
24
|
|
25
25
|
s.add_development_dependency 'rspec', '>= 2.6.0'
|
26
26
|
s.add_development_dependency 'cucumber', '< 1.2.0'
|
@@ -585,6 +585,72 @@ describe PageObject::ElementLocators do
|
|
585
585
|
watir_page_object.file_field_elements
|
586
586
|
end
|
587
587
|
|
588
|
+
it "should find an area element" do
|
589
|
+
watir_browser.should_receive(:area).with(:id => 'blah').and_return(watir_browser)
|
590
|
+
element = watir_page_object.area_element(:id => 'blah')
|
591
|
+
element.should be_instance_of PageObject::Elements::Area
|
592
|
+
end
|
593
|
+
|
594
|
+
it "should find an area element using a default identifier" do
|
595
|
+
watir_browser.should_receive(:area).with(:index => 0).and_return(watir_browser)
|
596
|
+
watir_page_object.area_element
|
597
|
+
end
|
598
|
+
|
599
|
+
it "should find all area elements" do
|
600
|
+
watir_browser.should_receive(:areas).with(:id => 'blah').and_return([watir_browser])
|
601
|
+
elements = watir_page_object.area_elements(:id => 'blah')
|
602
|
+
elements[0].should be_instance_of PageObject::Elements::Area
|
603
|
+
end
|
604
|
+
|
605
|
+
it "should find all areas with no identifier" do
|
606
|
+
watir_browser.should_receive(:areas).with({}).and_return([watir_browser])
|
607
|
+
watir_page_object.area_elements
|
608
|
+
end
|
609
|
+
|
610
|
+
it "should find a canvas element" do
|
611
|
+
watir_browser.should_receive(:canvas).with(:id => 'blah').and_return(watir_browser)
|
612
|
+
element = watir_page_object.canvas_element(:id => 'blah')
|
613
|
+
element.should be_instance_of PageObject::Elements::Canvas
|
614
|
+
end
|
615
|
+
|
616
|
+
it "should find a canvas element using a default identifier" do
|
617
|
+
watir_browser.should_receive(:canvas).with(:index => 0).and_return(watir_browser)
|
618
|
+
watir_page_object.canvas_element
|
619
|
+
end
|
620
|
+
|
621
|
+
it "should find all canvas elements" do
|
622
|
+
watir_browser.should_receive(:canvases).with(:id => 'blah').and_return([watir_browser])
|
623
|
+
elements = watir_page_object.canvas_elements(:id => 'blah')
|
624
|
+
elements[0].should be_instance_of PageObject::Elements::Canvas
|
625
|
+
end
|
626
|
+
|
627
|
+
it "should find all canvases with no identifier" do
|
628
|
+
watir_browser.should_receive(:canvases).with({}).and_return([watir_browser])
|
629
|
+
watir_page_object.canvas_elements
|
630
|
+
end
|
631
|
+
|
632
|
+
it "should find an audio element" do
|
633
|
+
watir_browser.should_receive(:audio).with(:id => 'blah').and_return(watir_browser)
|
634
|
+
element = watir_page_object.audio_element(:id => 'blah')
|
635
|
+
element.should be_instance_of PageObject::Elements::Audio
|
636
|
+
end
|
637
|
+
|
638
|
+
it "should find an audio element using a default identifier" do
|
639
|
+
watir_browser.should_receive(:audio).with(:index => 0).and_return(watir_browser)
|
640
|
+
watir_page_object.audio_element
|
641
|
+
end
|
642
|
+
|
643
|
+
it "should find all audio elements" do
|
644
|
+
watir_browser.should_receive(:audios).with(:id => 'blah').and_return([watir_browser])
|
645
|
+
elements = watir_page_object.audio_elements(:id => 'blah')
|
646
|
+
elements[0].should be_instance_of PageObject::Elements::Audio
|
647
|
+
end
|
648
|
+
|
649
|
+
it "should find all audio elements with no identifier" do
|
650
|
+
watir_browser.should_receive(:audios).with({}).and_return([watir_browser])
|
651
|
+
watir_page_object.audio_elements
|
652
|
+
end
|
653
|
+
|
588
654
|
it "should find an element" do
|
589
655
|
watir_browser.should_receive(:audio).with(:id => 'blah').and_return(watir_browser)
|
590
656
|
element = watir_page_object.element(:audio, :id => 'blah')
|
@@ -906,6 +972,72 @@ describe PageObject::ElementLocators do
|
|
906
972
|
selenium_browser.should_receive(:find_element).with(:id, 'blah').and_return(selenium_browser)
|
907
973
|
element = selenium_page_object.file_field_element(:id => 'blah')
|
908
974
|
element.should be_instance_of PageObject::Elements::FileField
|
975
|
+
end
|
976
|
+
|
977
|
+
it "should find an area element" do
|
978
|
+
selenium_browser.should_receive(:find_element).with(:id, 'blah').and_return(selenium_browser)
|
979
|
+
element = selenium_page_object.area_element(:id => 'blah')
|
980
|
+
element.should be_instance_of PageObject::Elements::Area
|
981
|
+
end
|
982
|
+
|
983
|
+
it "should find an area element using a default identifier" do
|
984
|
+
selenium_browser.should_receive(:find_element).with(:xpath, './/area[1]').and_return(selenium_browser)
|
985
|
+
selenium_page_object.area_element
|
986
|
+
end
|
987
|
+
|
988
|
+
it "should find all area elements" do
|
989
|
+
selenium_browser.should_receive(:find_elements).with(:id, 'blah').and_return([selenium_browser])
|
990
|
+
elements = selenium_page_object.area_elements(:id => 'blah')
|
991
|
+
elements[0].should be_instance_of PageObject::Elements::Area
|
992
|
+
end
|
993
|
+
|
994
|
+
it "should find all areas with no identifier" do
|
995
|
+
selenium_browser.should_receive(:find_elements).with(:tag_name, 'area').and_return([selenium_browser])
|
996
|
+
selenium_page_object.area_elements
|
997
|
+
end
|
998
|
+
|
999
|
+
it "should find a canvas element" do
|
1000
|
+
selenium_browser.should_receive(:find_element).with(:id, 'blah').and_return(selenium_browser)
|
1001
|
+
element = selenium_page_object.canvas_element(:id => 'blah')
|
1002
|
+
element.should be_instance_of PageObject::Elements::Canvas
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
it "should find a canvas element using a default identifier" do
|
1006
|
+
selenium_browser.should_receive(:find_element).with(:xpath, './/canvas[1]').and_return(selenium_browser)
|
1007
|
+
selenium_page_object.canvas_element
|
1008
|
+
end
|
1009
|
+
|
1010
|
+
it "should find all canvas elements" do
|
1011
|
+
selenium_browser.should_receive(:find_elements).with(:id, 'blah').and_return([selenium_browser])
|
1012
|
+
elements = selenium_page_object.canvas_elements(:id => 'blah')
|
1013
|
+
elements[0].should be_instance_of PageObject::Elements::Canvas
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
it "should find all canvases with no identifier" do
|
1017
|
+
selenium_browser.should_receive(:find_elements).with(:tag_name, 'canvas').and_return([selenium_browser])
|
1018
|
+
selenium_page_object.canvas_elements
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
it "should find an audio element" do
|
1022
|
+
selenium_browser.should_receive(:find_element).with(:id, 'blah').and_return(selenium_browser)
|
1023
|
+
element = selenium_page_object.audio_element(:id => 'blah')
|
1024
|
+
element.should be_instance_of PageObject::Elements::Audio
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
it "should find an audio element using a default identifier" do
|
1028
|
+
selenium_browser.should_receive(:find_element).with(:xpath, './/audio[1]').and_return(selenium_browser)
|
1029
|
+
selenium_page_object.audio_element
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
it "should find all audio elements" do
|
1033
|
+
selenium_browser.should_receive(:find_elements).with(:id, 'blah').and_return([selenium_browser])
|
1034
|
+
elements = selenium_page_object.audio_elements(:id => 'blah')
|
1035
|
+
elements[0].should be_instance_of PageObject::Elements::Audio
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
it "should find all audio elements with no identifier" do
|
1039
|
+
selenium_browser.should_receive(:find_elements).with(:tag_name, 'audio').and_return([selenium_browser])
|
1040
|
+
selenium_page_object.audio_elements
|
909
1041
|
end
|
910
1042
|
end
|
911
1043
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'page-object/elements'
|
3
|
+
|
4
|
+
describe PageObject::Elements::Canvas do
|
5
|
+
let(:area) { PageObject::Elements::Canvas }
|
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(:canvas_element) { double('canvas_element') }
|
25
|
+
|
26
|
+
context "when using selenium" do
|
27
|
+
let(:selenium_canvas) { PageObject::Elements::Canvas.new(canvas_element, :platform => :selenium_webdriver) }
|
28
|
+
|
29
|
+
it "should know its width" do
|
30
|
+
canvas_element.should_receive(:attribute).with(:width).and_return("400")
|
31
|
+
selenium_canvas.width.should == 400
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should know its height" do
|
35
|
+
canvas_element.should_receive(:attribute).with(:height).and_return("100")
|
36
|
+
selenium_canvas.height.should == 100
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -6,14 +6,14 @@ describe PageObject::Elements::ListItem do
|
|
6
6
|
|
7
7
|
describe "when mapping how to find an element" do
|
8
8
|
it "should map watir types to same" do
|
9
|
-
[:class, :id, :index, :xpath].each do |t|
|
9
|
+
[:class, :id, :index, :text, :xpath].each do |t|
|
10
10
|
identifier = list_item.watir_identifier_for t => 'value'
|
11
11
|
identifier.keys.first.should == t
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should map selenium types to same" do
|
16
|
-
[:class, :id, :index, :name, :xpath].each do |t|
|
16
|
+
[:class, :id, :index, :name, :text, :xpath].each do |t|
|
17
17
|
key, value = list_item.selenium_identifier_for t => 'value'
|
18
18
|
key.should == t
|
19
19
|
end
|
@@ -31,6 +31,9 @@ class SeleniumAccessorsTestPageObject
|
|
31
31
|
h6(:heading6, :id => 'main_heading')
|
32
32
|
paragraph(:first_para, :id => 'first')
|
33
33
|
file_field(:upload_me, :id => 'the_file')
|
34
|
+
area(:img_area, :id => 'area')
|
35
|
+
canvas(:my_canvas, :id => 'canvas')
|
36
|
+
audio(:acdc, :id => 'audio_id')
|
34
37
|
end
|
35
38
|
|
36
39
|
class SeleniumBlockPageObject
|
@@ -113,12 +116,21 @@ class SeleniumBlockPageObject
|
|
113
116
|
file_field :a_file do |element|
|
114
117
|
"file_field"
|
115
118
|
end
|
119
|
+
area :img_area do |element|
|
120
|
+
"area"
|
121
|
+
end
|
122
|
+
canvas :my_canvas do |element|
|
123
|
+
"canvas"
|
124
|
+
end
|
125
|
+
audio :acdc do |element|
|
126
|
+
'audio'
|
127
|
+
end
|
116
128
|
end
|
117
129
|
|
118
130
|
describe PageObject::Accessors do
|
119
131
|
let(:selenium_browser) { mock_selenium_browser }
|
120
132
|
let(:selenium_page_object) { SeleniumAccessorsTestPageObject.new(selenium_browser) }
|
121
|
-
let(:block_page_object) { SeleniumBlockPageObject.new(
|
133
|
+
let(:block_page_object) { SeleniumBlockPageObject.new(selenium_browser) }
|
122
134
|
|
123
135
|
before(:each) do
|
124
136
|
selenium_browser.stub(:switch_to).and_return(selenium_browser)
|
@@ -502,4 +514,53 @@ describe PageObject::Accessors do
|
|
502
514
|
element.should be_instance_of PageObject::Elements::FileField
|
503
515
|
end
|
504
516
|
end
|
517
|
+
|
518
|
+
describe "area accessors" do
|
519
|
+
context "when called on a page object" do
|
520
|
+
it "should generate accessor methods" do
|
521
|
+
selenium_page_object.should respond_to(:img_area)
|
522
|
+
selenium_page_object.should respond_to(:img_area_element)
|
523
|
+
end
|
524
|
+
|
525
|
+
it "should call a block on the element method when present" do
|
526
|
+
block_page_object.img_area_element.should == "area"
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
it "should click on the area" do
|
531
|
+
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
532
|
+
selenium_browser.should_receive(:click)
|
533
|
+
selenium_page_object.img_area
|
534
|
+
end
|
535
|
+
|
536
|
+
it "should retrieve the element from the page" do
|
537
|
+
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
538
|
+
element = selenium_page_object.img_area_element
|
539
|
+
element.should be_instance_of PageObject::Elements::Area
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
describe "canvas accessors" do
|
544
|
+
context "when called on a page object" do
|
545
|
+
it "should generate accessor methods" do
|
546
|
+
selenium_page_object.should respond_to(:my_canvas_element)
|
547
|
+
end
|
548
|
+
|
549
|
+
it "should call a block on the element method when present" do
|
550
|
+
block_page_object.my_canvas_element.should == "canvas"
|
551
|
+
end
|
552
|
+
end
|
553
|
+
end
|
554
|
+
|
555
|
+
describe "audio accessors" do
|
556
|
+
context "when called on a page object" do
|
557
|
+
it "should generate accessor methods" do
|
558
|
+
selenium_page_object.should respond_to(:acdc_element)
|
559
|
+
end
|
560
|
+
|
561
|
+
it "should call a block on the element method when present" do
|
562
|
+
block_page_object.acdc_element.should == "audio"
|
563
|
+
end
|
564
|
+
end
|
565
|
+
end
|
505
566
|
end
|
@@ -31,6 +31,9 @@ class WatirAccessorsTestPageObject
|
|
31
31
|
h6(:heading6, :id => 'main_heading')
|
32
32
|
paragraph(:first_para, :id => 'first')
|
33
33
|
file_field(:upload_me, :id => 'the_file')
|
34
|
+
area(:img_area, :id => 'area')
|
35
|
+
canvas(:my_canvas, :id => 'canvas_id')
|
36
|
+
audio(:acdc, :id => 'audio_id')
|
34
37
|
end
|
35
38
|
|
36
39
|
class WatirBlockPageObject
|
@@ -113,6 +116,15 @@ class WatirBlockPageObject
|
|
113
116
|
file_field :a_file do |element|
|
114
117
|
"file_field"
|
115
118
|
end
|
119
|
+
area :img_area do |element|
|
120
|
+
"area"
|
121
|
+
end
|
122
|
+
canvas :my_canvas do |element|
|
123
|
+
"canvas"
|
124
|
+
end
|
125
|
+
audio :acdc do |element|
|
126
|
+
"audio"
|
127
|
+
end
|
116
128
|
end
|
117
129
|
|
118
130
|
describe PageObject::Accessors do
|
@@ -1025,4 +1037,53 @@ describe PageObject::Accessors do
|
|
1025
1037
|
element.should be_instance_of PageObject::Elements::FileField
|
1026
1038
|
end
|
1027
1039
|
end
|
1040
|
+
|
1041
|
+
describe "area accessors" do
|
1042
|
+
context "when called on a page object" do
|
1043
|
+
it "should generate accessor methods" do
|
1044
|
+
watir_page_object.should respond_to(:img_area)
|
1045
|
+
watir_page_object.should respond_to(:img_area_element)
|
1046
|
+
end
|
1047
|
+
|
1048
|
+
it "should call a block on the element method when present" do
|
1049
|
+
block_page_object.img_area_element.should == "area"
|
1050
|
+
end
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
it "should click on the area" do
|
1054
|
+
watir_browser.should_receive(:area).and_return(watir_browser)
|
1055
|
+
watir_browser.should_receive(:click)
|
1056
|
+
watir_page_object.img_area
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
it "should retrieve the element from the page" do
|
1060
|
+
watir_browser.should_receive(:area).and_return(watir_browser)
|
1061
|
+
element = watir_page_object.img_area_element
|
1062
|
+
element.should be_instance_of PageObject::Elements::Area
|
1063
|
+
end
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
describe "canvas accessors" do
|
1067
|
+
context "when called on a page object" do
|
1068
|
+
it "should generate accessor methods" do
|
1069
|
+
watir_page_object.should respond_to(:my_canvas_element)
|
1070
|
+
end
|
1071
|
+
|
1072
|
+
it "should call a block on the element method when present" do
|
1073
|
+
block_page_object.my_canvas_element.should == "canvas"
|
1074
|
+
end
|
1075
|
+
end
|
1076
|
+
end
|
1077
|
+
|
1078
|
+
describe "audio accessors" do
|
1079
|
+
context "when called on a page object" do
|
1080
|
+
it "should generate accessor methods" do
|
1081
|
+
watir_page_object.should respond_to(:acdc_element)
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
it "should call a block on the element method when present" do
|
1085
|
+
block_page_object.acdc_element.should == "audio"
|
1086
|
+
end
|
1087
|
+
end
|
1088
|
+
end
|
1028
1089
|
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.2
|
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-08-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.
|
37
|
+
version: 2.25.0
|
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.25.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rspec
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +127,9 @@ files:
|
|
127
127
|
- cucumber.yml
|
128
128
|
- features/area.feature
|
129
129
|
- features/async.feature
|
130
|
+
- features/audio.feature
|
130
131
|
- features/button.feature
|
132
|
+
- features/canvas.feature
|
131
133
|
- features/check_box.feature
|
132
134
|
- features/div.feature
|
133
135
|
- features/element.feature
|
@@ -183,7 +185,9 @@ files:
|
|
183
185
|
- features/step_definitions/accessor_steps.rb
|
184
186
|
- features/step_definitions/area_steps.rb
|
185
187
|
- features/step_definitions/async_steps.rb
|
188
|
+
- features/step_definitions/audio_steps.rb
|
186
189
|
- features/step_definitions/button_steps.rb
|
190
|
+
- features/step_definitions/canvas_steps.rb
|
187
191
|
- features/step_definitions/check_box_steps.rb
|
188
192
|
- features/step_definitions/div_steps.rb
|
189
193
|
- features/step_definitions/element_steps.rb
|
@@ -231,7 +235,9 @@ files:
|
|
231
235
|
- lib/page-object/element_locators.rb
|
232
236
|
- lib/page-object/elements.rb
|
233
237
|
- lib/page-object/elements/area.rb
|
238
|
+
- lib/page-object/elements/audio.rb
|
234
239
|
- lib/page-object/elements/button.rb
|
240
|
+
- lib/page-object/elements/canvas.rb
|
235
241
|
- lib/page-object/elements/check_box.rb
|
236
242
|
- lib/page-object/elements/div.rb
|
237
243
|
- lib/page-object/elements/element.rb
|
@@ -303,6 +309,7 @@ files:
|
|
303
309
|
- spec/page-object/element_locators_spec.rb
|
304
310
|
- spec/page-object/elements/area_spec.rb
|
305
311
|
- spec/page-object/elements/button_spec.rb
|
312
|
+
- spec/page-object/elements/canvas_spec.rb
|
306
313
|
- spec/page-object/elements/check_box_spec.rb
|
307
314
|
- spec/page-object/elements/div_spec.rb
|
308
315
|
- spec/page-object/elements/element_spec.rb
|
@@ -354,7 +361,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
354
361
|
version: '0'
|
355
362
|
segments:
|
356
363
|
- 0
|
357
|
-
hash: -
|
364
|
+
hash: -4250086403219071004
|
358
365
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
359
366
|
none: false
|
360
367
|
requirements:
|
@@ -363,7 +370,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
363
370
|
version: '0'
|
364
371
|
segments:
|
365
372
|
- 0
|
366
|
-
hash: -
|
373
|
+
hash: -4250086403219071004
|
367
374
|
requirements: []
|
368
375
|
rubyforge_project: page-object
|
369
376
|
rubygems_version: 1.8.24
|
@@ -373,7 +380,9 @@ summary: Page Object DSL for browser testing
|
|
373
380
|
test_files:
|
374
381
|
- features/area.feature
|
375
382
|
- features/async.feature
|
383
|
+
- features/audio.feature
|
376
384
|
- features/button.feature
|
385
|
+
- features/canvas.feature
|
377
386
|
- features/check_box.feature
|
378
387
|
- features/div.feature
|
379
388
|
- features/element.feature
|
@@ -429,7 +438,9 @@ test_files:
|
|
429
438
|
- features/step_definitions/accessor_steps.rb
|
430
439
|
- features/step_definitions/area_steps.rb
|
431
440
|
- features/step_definitions/async_steps.rb
|
441
|
+
- features/step_definitions/audio_steps.rb
|
432
442
|
- features/step_definitions/button_steps.rb
|
443
|
+
- features/step_definitions/canvas_steps.rb
|
433
444
|
- features/step_definitions/check_box_steps.rb
|
434
445
|
- features/step_definitions/div_steps.rb
|
435
446
|
- features/step_definitions/element_steps.rb
|
@@ -474,6 +485,7 @@ test_files:
|
|
474
485
|
- spec/page-object/element_locators_spec.rb
|
475
486
|
- spec/page-object/elements/area_spec.rb
|
476
487
|
- spec/page-object/elements/button_spec.rb
|
488
|
+
- spec/page-object/elements/canvas_spec.rb
|
477
489
|
- spec/page-object/elements/check_box_spec.rb
|
478
490
|
- spec/page-object/elements/div_spec.rb
|
479
491
|
- spec/page-object/elements/element_spec.rb
|