page-object 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -1
- data/ChangeLog +12 -6
- data/README.md +1 -1
- data/Rakefile +3 -19
- data/features/async.feature +8 -8
- data/features/button.feature +7 -7
- data/features/check_box.feature +8 -8
- data/features/div.feature +7 -6
- data/features/element_attributes.feature +14 -14
- data/features/form.feature +5 -5
- data/features/frames.feature +12 -0
- data/features/hidden_field.feature +5 -5
- data/features/html/frame_1.html +18 -0
- data/features/html/frame_2.html +16 -0
- data/features/html/frames.html +11 -0
- data/features/html/iframes.html +12 -0
- data/features/html/static_elements.html +50 -42
- data/features/html/success.html +5 -5
- data/features/image.feature +11 -11
- data/features/link.feature +1 -1
- data/features/list_item.feature +5 -5
- data/features/ordered_list.feature +6 -6
- data/features/page_level_actions.feature +16 -5
- data/features/radio_button.feature +12 -12
- data/features/select_list.feature +12 -12
- data/features/span.feature +5 -5
- data/features/step_definitions/accessor_steps.rb +2 -2
- data/features/step_definitions/async_steps.rb +1 -1
- data/features/step_definitions/element_steps.rb +1 -1
- data/features/step_definitions/frames_steps.rb +21 -0
- data/features/step_definitions/page_level_actions_steps.rb +24 -2
- data/features/step_definitions/page_traversal_steps.rb +0 -1
- data/features/support/env.rb +20 -6
- data/features/support/page.rb +14 -11
- data/features/support/url_helper.rb +4 -0
- data/features/table.feature +9 -9
- data/features/table_cell.feature +6 -6
- data/features/text_area.feature +6 -6
- data/features/text_field.feature +7 -7
- data/features/unordered_list.feature +6 -6
- data/lib/page-object.rb +40 -16
- data/lib/page-object/accessors.rb +15 -15
- data/lib/page-object/elements.rb +0 -1
- data/lib/page-object/elements/button.rb +24 -24
- data/lib/page-object/elements/div.rb +8 -3
- data/lib/page-object/elements/element.rb +27 -28
- data/lib/page-object/elements/form.rb +7 -7
- data/lib/page-object/elements/hidden_field.rb +5 -5
- data/lib/page-object/elements/image.rb +8 -8
- data/lib/page-object/elements/link.rb +9 -9
- data/lib/page-object/elements/list_item.rb +1 -1
- data/lib/page-object/elements/option.rb +1 -1
- data/lib/page-object/elements/ordered_list.rb +13 -13
- data/lib/page-object/elements/select_list.rb +6 -6
- data/lib/page-object/elements/span.rb +2 -2
- data/lib/page-object/elements/table.rb +11 -11
- data/lib/page-object/elements/table_row.rb +9 -9
- data/lib/page-object/elements/text_area.rb +4 -4
- data/lib/page-object/elements/text_field.rb +4 -4
- data/lib/page-object/elements/unordered_list.rb +13 -13
- data/lib/page-object/loads_platform.rb +24 -0
- data/lib/page-object/page_factory.rb +3 -3
- data/lib/page-object/platforms.rb +18 -0
- data/lib/page-object/platforms/selenium.rb +16 -0
- data/lib/page-object/platforms/selenium/button.rb +15 -0
- data/lib/page-object/platforms/selenium/element.rb +168 -0
- data/lib/page-object/platforms/selenium/form.rb +16 -0
- data/lib/page-object/platforms/selenium/image.rb +28 -0
- data/lib/page-object/platforms/selenium/link.rb +16 -0
- data/lib/page-object/platforms/selenium/ordered_list.rb +33 -0
- data/lib/page-object/platforms/selenium/page_object.rb +524 -0
- data/lib/page-object/platforms/selenium/select_list.rb +32 -0
- data/lib/page-object/platforms/selenium/table.rb +40 -0
- data/lib/page-object/platforms/selenium/table_row.rb +32 -0
- data/lib/page-object/platforms/selenium/unordered_list.rb +33 -0
- data/lib/page-object/platforms/watir.rb +16 -0
- data/lib/page-object/platforms/watir/element.rb +154 -0
- data/lib/page-object/platforms/watir/form.rb +16 -0
- data/lib/page-object/platforms/watir/image.rb +22 -0
- data/lib/page-object/platforms/watir/ordered_list.rb +32 -0
- data/lib/page-object/{watir_page_object.rb → platforms/watir/page_object.rb} +62 -35
- data/lib/page-object/platforms/watir/select_list.rb +33 -0
- data/lib/page-object/platforms/watir/table.rb +27 -0
- data/lib/page-object/platforms/watir/table_row.rb +24 -0
- data/lib/page-object/platforms/watir/unordered_list.rb +33 -0
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +13 -13
- data/spec/page-object/accessors_spec.rb +142 -108
- data/spec/page-object/elements/button_spec.rb +33 -33
- data/spec/page-object/elements/check_box_spec.rb +1 -1
- data/spec/page-object/elements/div_spec.rb +3 -3
- data/spec/page-object/elements/element_spec.rb +51 -41
- data/spec/page-object/elements/form_spec.rb +3 -3
- data/spec/page-object/elements/hidden_field_spec.rb +3 -3
- data/spec/page-object/elements/image_spec.rb +7 -7
- data/spec/page-object/elements/link_spec.rb +8 -8
- data/spec/page-object/elements/list_item_spec.rb +1 -1
- data/spec/page-object/elements/ordered_list_spec.rb +9 -9
- data/spec/page-object/elements/radio_button_spec.rb +1 -1
- data/spec/page-object/elements/select_list_spec.rb +2 -2
- data/spec/page-object/elements/span_spec.rb +1 -1
- data/spec/page-object/elements/table_row_spec.rb +6 -6
- data/spec/page-object/elements/table_spec.rb +9 -9
- data/spec/page-object/elements/text_area_spec.rb +3 -3
- data/spec/page-object/elements/text_field_spec.rb +3 -3
- data/spec/page-object/elements/unordered_list_spec.rb +10 -10
- data/spec/page-object/loads_platform_spec.rb +38 -0
- data/spec/page-object/page-object_spec.rb +70 -10
- data/spec/page-object/page_factory_spec.rb +3 -3
- data/spec/page-object/{selenium_page_object_spec.rb → platforms/selenium/selenium_page_object_spec.rb} +10 -3
- data/spec/page-object/platforms/selenium_spec.rb +26 -0
- data/spec/page-object/platforms/watir_spec.rb +27 -0
- data/spec/spec_helper.rb +18 -5
- metadata +48 -26
- data/lib/page-object/platforms/selenium_button.rb +0 -13
- data/lib/page-object/platforms/selenium_element.rb +0 -142
- data/lib/page-object/platforms/selenium_form.rb +0 -14
- data/lib/page-object/platforms/selenium_image.rb +0 -26
- data/lib/page-object/platforms/selenium_link.rb +0 -13
- data/lib/page-object/platforms/selenium_ordered_list.rb +0 -31
- data/lib/page-object/platforms/selenium_select_list.rb +0 -29
- data/lib/page-object/platforms/selenium_table.rb +0 -38
- data/lib/page-object/platforms/selenium_table_row.rb +0 -29
- data/lib/page-object/platforms/selenium_unordered_list.rb +0 -31
- data/lib/page-object/platforms/watir_element.rb +0 -136
- data/lib/page-object/platforms/watir_form.rb +0 -14
- data/lib/page-object/platforms/watir_image.rb +0 -20
- data/lib/page-object/platforms/watir_ordered_list.rb +0 -30
- data/lib/page-object/platforms/watir_select_list.rb +0 -30
- data/lib/page-object/platforms/watir_table.rb +0 -24
- data/lib/page-object/platforms/watir_table_row.rb +0 -22
- data/lib/page-object/platforms/watir_unordered_list.rb +0 -31
- data/lib/page-object/selenium_page_object.rb +0 -486
@@ -0,0 +1,33 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Watir
|
4
|
+
module SelectList
|
5
|
+
|
6
|
+
#
|
7
|
+
# Return the PageObject::Elements::Option for the index provided. Index
|
8
|
+
# is zero based.
|
9
|
+
#
|
10
|
+
# @return [PageObject::Elements::Option]
|
11
|
+
#
|
12
|
+
def [](idx)
|
13
|
+
PageObject::Elements::Option.new(options[idx], :platform => :watir)
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Return an array of Options contained in the select lit.
|
18
|
+
#
|
19
|
+
# @return [array of PageObject::Elements::Option]
|
20
|
+
#
|
21
|
+
def options
|
22
|
+
elements = []
|
23
|
+
options = @element.wd.find_elements(:xpath, child_xpath)
|
24
|
+
options.each do |opt|
|
25
|
+
elements << PageObject::Elements::Option.new(opt, :platform => :watir)
|
26
|
+
end
|
27
|
+
elements
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Watir
|
4
|
+
|
5
|
+
module Table
|
6
|
+
|
7
|
+
#
|
8
|
+
# Return the PageObject::Elements::TableRow for the index provided. Index
|
9
|
+
# is zero based.
|
10
|
+
#
|
11
|
+
# @return [PageObject::Elements::TableRow]
|
12
|
+
#
|
13
|
+
def [](idx)
|
14
|
+
PageObject::Elements::TableRow.new(@element[idx], :platform => :watir)
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Returns the number of rows in the table.
|
19
|
+
#
|
20
|
+
def rows
|
21
|
+
element.wd.find_elements(:xpath, child_xpath).size
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Watir
|
4
|
+
module TableRow
|
5
|
+
|
6
|
+
#
|
7
|
+
# Return the PageObject::Elements::TableCell for the index provided. Index
|
8
|
+
# is zero based.
|
9
|
+
#
|
10
|
+
def [](idx)
|
11
|
+
PageObject::Elements::TableCell.new(element[idx], :platform => :watir)
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# Returns the number of columns in the table.
|
16
|
+
#
|
17
|
+
def columns
|
18
|
+
element.wd.find_elements(:xpath, child_xpath).size
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module PageObject
|
2
|
+
module Platforms
|
3
|
+
module Watir
|
4
|
+
module UnorderedList
|
5
|
+
|
6
|
+
#
|
7
|
+
# Return the PageObject::Elements::ListItem for the index provided. Index
|
8
|
+
# is zero based.
|
9
|
+
#
|
10
|
+
# @return [PageObject::Elements::ListItem]
|
11
|
+
#
|
12
|
+
def [](idx)
|
13
|
+
eles = list_items
|
14
|
+
PageObject::Elements::ListItem.new(eles[idx], :platform => :watir)
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Return the number of items contained in the unordered list
|
19
|
+
#
|
20
|
+
def items
|
21
|
+
list_items.size
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def list_items
|
27
|
+
element.wd.find_elements(:xpath, child_xpath)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/page-object/version.rb
CHANGED
data/page-object.gemspec
CHANGED
@@ -3,27 +3,27 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
require "page-object/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name
|
7
|
-
s.version
|
8
|
-
s.platform
|
9
|
-
s.authors
|
10
|
-
s.email
|
11
|
-
s.homepage
|
12
|
-
s.summary
|
6
|
+
s.name = "page-object"
|
7
|
+
s.version = PageObject::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jeff Morgan"]
|
10
|
+
s.email = ["jeff.morgan@leandog.com"]
|
11
|
+
s.homepage = "http://github.com/cheezy/page-object"
|
12
|
+
s.summary = %q{Page Object DSL for browser testing}
|
13
13
|
s.description = %q{Page Object DSL that works with both Watir and Selenium}
|
14
14
|
|
15
15
|
s.rubyforge_project = "page-object"
|
16
16
|
|
17
|
-
s.files
|
18
|
-
s.test_files
|
19
|
-
s.executables
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
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.2.
|
23
|
-
s.add_dependency 'selenium-webdriver', '>= 2.
|
22
|
+
s.add_dependency 'watir-webdriver', '>= 0.2.8'
|
23
|
+
s.add_dependency 'selenium-webdriver', '>= 2.2.0'
|
24
24
|
|
25
25
|
s.add_development_dependency 'rspec', '>= 2.6.0'
|
26
26
|
s.add_development_dependency 'cucumber', '>= 1.0.0'
|
27
27
|
s.add_development_dependency 'yard', '>= 0.7.2'
|
28
|
-
|
28
|
+
|
29
29
|
end
|
@@ -11,7 +11,7 @@ class AccessorsTestPageObject
|
|
11
11
|
select_list(:state, :id => 'state')
|
12
12
|
checkbox(:active, :id => 'is_active_id')
|
13
13
|
radio_button(:first, :id => 'first_choice')
|
14
|
-
button(:click_me,
|
14
|
+
button(:click_me, :id => 'button_submit')
|
15
15
|
div(:message, :id => 'message_id')
|
16
16
|
table(:cart, :id => 'cart_id')
|
17
17
|
cell(:total, :id => 'total')
|
@@ -25,26 +25,60 @@ end
|
|
25
25
|
|
26
26
|
class BlockPageObject
|
27
27
|
include PageObject
|
28
|
-
|
29
|
-
attr_reader :value
|
30
|
-
|
31
|
-
text_field :first_name do |browser|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
28
|
+
|
29
|
+
attr_reader :value
|
30
|
+
|
31
|
+
text_field :first_name do |browser|
|
32
|
+
"text_field"
|
33
|
+
end
|
34
|
+
hidden_field :secret do |browser|
|
35
|
+
"hidden_field"
|
36
|
+
end
|
37
|
+
text_area :address do |browser|
|
38
|
+
"text_area"
|
39
|
+
end
|
40
|
+
select_list :state do |browser|
|
41
|
+
"select_list"
|
42
|
+
end
|
43
|
+
link :continue do |browser|
|
44
|
+
"link"
|
45
|
+
end
|
46
|
+
checkbox :active do |browser|
|
47
|
+
"checkbox"
|
48
|
+
end
|
49
|
+
radio_button :first do |browser|
|
50
|
+
"radio_button"
|
51
|
+
end
|
52
|
+
button :click_me do |browser|
|
53
|
+
"button"
|
54
|
+
end
|
55
|
+
div :footer do |browser|
|
56
|
+
"div"
|
57
|
+
end
|
58
|
+
span :alert do |browser|
|
59
|
+
"span"
|
60
|
+
end
|
61
|
+
table :cart do |browser|
|
62
|
+
"table"
|
63
|
+
end
|
64
|
+
cell :total do |browser|
|
65
|
+
"cell"
|
66
|
+
end
|
67
|
+
image :logo do |browser|
|
68
|
+
"image"
|
69
|
+
end
|
70
|
+
form :login do |browser|
|
71
|
+
"form"
|
72
|
+
end
|
73
|
+
list_item :item_one do |browser|
|
74
|
+
"list_item"
|
75
|
+
end
|
76
|
+
unordered_list :menu do |browser|
|
77
|
+
"unordered_list"
|
78
|
+
end
|
79
|
+
ordered_list :top_five do |browser|
|
80
|
+
"ordered_list"
|
81
|
+
end
|
48
82
|
end
|
49
83
|
|
50
84
|
describe PageObject::Accessors do
|
@@ -53,31 +87,31 @@ describe PageObject::Accessors do
|
|
53
87
|
let(:watir_page_object) { AccessorsTestPageObject.new(watir_browser) }
|
54
88
|
let(:selenium_page_object) { AccessorsTestPageObject.new(selenium_browser) }
|
55
89
|
let(:block_page_object) { BlockPageObject.new(watir_browser) }
|
56
|
-
|
90
|
+
|
57
91
|
describe "goto a page" do
|
58
92
|
it "should navigate to a page when requested" do
|
59
93
|
watir_browser.should_receive(:goto)
|
60
94
|
page = AccessorsTestPageObject.new(watir_browser, true)
|
61
95
|
end
|
62
|
-
|
96
|
+
|
63
97
|
it "should not navigate to a page when not requested" do
|
64
98
|
watir_browser.should_not_receive(:goto)
|
65
99
|
page = AccessorsTestPageObject.new(watir_browser)
|
66
100
|
end
|
67
|
-
|
101
|
+
|
68
102
|
it "should not navigate to a page when 'page_url' not specified" do
|
69
103
|
watir_browser.should_not_receive(:goto)
|
70
104
|
page = BlockPageObject.new(watir_browser, true)
|
71
105
|
end
|
72
106
|
end
|
73
|
-
|
107
|
+
|
74
108
|
describe "link accessors" do
|
75
109
|
context "when called on a page object" do
|
76
110
|
it "should generate accessor methods" do
|
77
111
|
watir_page_object.should respond_to(:google_search)
|
78
112
|
watir_page_object.should respond_to(:google_search_link)
|
79
113
|
end
|
80
|
-
|
114
|
+
|
81
115
|
it "should call a block on the element method when present" do
|
82
116
|
block_page_object.continue_link.should == "link"
|
83
117
|
end
|
@@ -88,7 +122,7 @@ describe PageObject::Accessors do
|
|
88
122
|
watir_browser.stub_chain(:link, :click)
|
89
123
|
watir_page_object.google_search
|
90
124
|
end
|
91
|
-
|
125
|
+
|
92
126
|
it "should return a link element" do
|
93
127
|
watir_browser.should_receive(:link).and_return(watir_browser)
|
94
128
|
element = watir_page_object.google_search_link
|
@@ -101,7 +135,7 @@ describe PageObject::Accessors do
|
|
101
135
|
selenium_browser.stub_chain(:find_element, :click)
|
102
136
|
selenium_page_object.google_search
|
103
137
|
end
|
104
|
-
|
138
|
+
|
105
139
|
it "should return a link element" do
|
106
140
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
107
141
|
element = selenium_page_object.google_search_link
|
@@ -118,7 +152,7 @@ describe PageObject::Accessors do
|
|
118
152
|
watir_page_object.should respond_to(:first_name=)
|
119
153
|
watir_page_object.should respond_to(:first_name_text_field)
|
120
154
|
end
|
121
|
-
|
155
|
+
|
122
156
|
it "should call a block on the element method when present" do
|
123
157
|
block_page_object.first_name_text_field.should == "text_field"
|
124
158
|
end
|
@@ -130,13 +164,13 @@ describe PageObject::Accessors do
|
|
130
164
|
watir_browser.should_receive(:value).and_return('Kim')
|
131
165
|
watir_page_object.first_name.should == 'Kim'
|
132
166
|
end
|
133
|
-
|
167
|
+
|
134
168
|
it "should set some text on a text field element" do
|
135
169
|
watir_browser.should_receive(:text_field).and_return(watir_browser)
|
136
170
|
watir_browser.should_receive(:set).with('Kim')
|
137
171
|
watir_page_object.first_name = 'Kim'
|
138
172
|
end
|
139
|
-
|
173
|
+
|
140
174
|
it "should retrieve a text field element" do
|
141
175
|
watir_browser.should_receive(:text_field).and_return(watir_browser)
|
142
176
|
element = watir_page_object.first_name_text_field
|
@@ -156,7 +190,7 @@ describe PageObject::Accessors do
|
|
156
190
|
selenium_browser.should_receive(:send_keys).with('Katie')
|
157
191
|
selenium_page_object.first_name = 'Katie'
|
158
192
|
end
|
159
|
-
|
193
|
+
|
160
194
|
it "should retrieve a text field element" do
|
161
195
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
162
196
|
element = selenium_page_object.first_name_text_field
|
@@ -164,20 +198,20 @@ describe PageObject::Accessors do
|
|
164
198
|
end
|
165
199
|
end
|
166
200
|
end
|
167
|
-
|
168
|
-
|
201
|
+
|
202
|
+
|
169
203
|
describe "hidden field accessors" do
|
170
204
|
context "when called on a page object" do
|
171
205
|
it "should generate accessor methods" do
|
172
206
|
watir_page_object.should respond_to(:social_security_number)
|
173
207
|
watir_page_object.should respond_to(:social_security_number_hidden_field)
|
174
208
|
end
|
175
|
-
|
209
|
+
|
176
210
|
it "should call a block on the element method when present" do
|
177
211
|
block_page_object.secret_hidden_field.should == "hidden_field"
|
178
212
|
end
|
179
213
|
end
|
180
|
-
|
214
|
+
|
181
215
|
context "watir implementation" do
|
182
216
|
it "should get the text from a hidden field" do
|
183
217
|
watir_browser.should_receive(:hidden).and_return(watir_browser)
|
@@ -191,14 +225,14 @@ describe PageObject::Accessors do
|
|
191
225
|
element.should be_instance_of(PageObject::Elements::HiddenField)
|
192
226
|
end
|
193
227
|
end
|
194
|
-
|
228
|
+
|
195
229
|
context "selenium implementation" do
|
196
230
|
it "should get the text from a hidden field" do
|
197
231
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
198
232
|
selenium_browser.should_receive(:attribute).with('value').and_return("12345")
|
199
233
|
selenium_page_object.social_security_number.should == "12345"
|
200
234
|
end
|
201
|
-
|
235
|
+
|
202
236
|
it "should retrieve a hidden field element" do
|
203
237
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
204
238
|
element = selenium_page_object.social_security_number_hidden_field
|
@@ -206,7 +240,7 @@ describe PageObject::Accessors do
|
|
206
240
|
end
|
207
241
|
end
|
208
242
|
end
|
209
|
-
|
243
|
+
|
210
244
|
describe "text area accessors" do
|
211
245
|
context "when called on a page object" do
|
212
246
|
it "should generate accessor methods" do
|
@@ -219,40 +253,40 @@ describe PageObject::Accessors do
|
|
219
253
|
block_page_object.address_text_area.should == "text_area"
|
220
254
|
end
|
221
255
|
end
|
222
|
-
|
256
|
+
|
223
257
|
context "watir implementation" do
|
224
258
|
it "should set some text on the text area" do
|
225
259
|
watir_browser.should_receive(:textarea).and_return(watir_browser)
|
226
260
|
watir_browser.should_receive(:send_keys).with("123 main street")
|
227
261
|
watir_page_object.address = "123 main street"
|
228
262
|
end
|
229
|
-
|
263
|
+
|
230
264
|
it "should get the text from the text area" do
|
231
265
|
watir_browser.should_receive(:textarea).and_return(watir_browser)
|
232
266
|
watir_browser.should_receive(:value).and_return("123 main street")
|
233
267
|
watir_page_object.address.should == "123 main street"
|
234
268
|
end
|
235
|
-
|
269
|
+
|
236
270
|
it "should retrieve a text area element" do
|
237
271
|
watir_browser.should_receive(:textarea).and_return(watir_browser)
|
238
272
|
element = watir_page_object.address_text_area
|
239
273
|
element.should be_instance_of PageObject::Elements::TextArea
|
240
274
|
end
|
241
275
|
end
|
242
|
-
|
276
|
+
|
243
277
|
context "selenium implementation" do
|
244
278
|
it "should set some text on the text area" do
|
245
279
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
246
280
|
selenium_browser.should_receive(:send_keys).with("123 main street")
|
247
281
|
selenium_page_object.address = "123 main street"
|
248
282
|
end
|
249
|
-
|
283
|
+
|
250
284
|
it "should get the text from the text area" do
|
251
285
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
252
286
|
selenium_browser.should_receive(:attribute).with('value').and_return("123 main street")
|
253
287
|
selenium_page_object.address.should == "123 main street"
|
254
288
|
end
|
255
|
-
|
289
|
+
|
256
290
|
it "should retrieve a text area element" do
|
257
291
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
258
292
|
element = selenium_page_object.address_text_area
|
@@ -273,40 +307,40 @@ describe PageObject::Accessors do
|
|
273
307
|
block_page_object.state_select_list.should == "select_list"
|
274
308
|
end
|
275
309
|
end
|
276
|
-
|
310
|
+
|
277
311
|
context "Watir implementation" do
|
278
312
|
it "should get the current item from a select list" do
|
279
313
|
watir_browser.should_receive(:select_list).and_return watir_browser
|
280
314
|
watir_browser.should_receive(:value).and_return("OH")
|
281
315
|
watir_page_object.state.should == "OH"
|
282
316
|
end
|
283
|
-
|
317
|
+
|
284
318
|
it "should set the current item of a select list" do
|
285
319
|
watir_browser.should_receive(:select_list).and_return watir_browser
|
286
320
|
watir_browser.should_receive(:select).with("OH")
|
287
321
|
watir_page_object.state = "OH"
|
288
322
|
end
|
289
|
-
|
323
|
+
|
290
324
|
it "should retreive the select list element" do
|
291
325
|
watir_browser.should_receive(:select_list).and_return(watir_browser)
|
292
326
|
element = watir_page_object.state_select_list
|
293
327
|
element.should be_instance_of PageObject::Elements::SelectList
|
294
328
|
end
|
295
329
|
end
|
296
|
-
|
330
|
+
|
297
331
|
context "Selenium implementation" do
|
298
332
|
it "should should get the current item from a select list" do
|
299
333
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
300
334
|
selenium_browser.should_receive(:attribute).and_return("OH")
|
301
335
|
selenium_page_object.state.should == "OH"
|
302
336
|
end
|
303
|
-
|
337
|
+
|
304
338
|
it "should set the current item of a select list" do
|
305
339
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
306
340
|
selenium_browser.should_receive(:send_keys).with("OH")
|
307
341
|
selenium_page_object.state = "OH"
|
308
342
|
end
|
309
|
-
|
343
|
+
|
310
344
|
it "should retrieve the select list element" do
|
311
345
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
312
346
|
element = selenium_page_object.state_select_list
|
@@ -315,7 +349,7 @@ describe PageObject::Accessors do
|
|
315
349
|
end
|
316
350
|
end
|
317
351
|
|
318
|
-
|
352
|
+
|
319
353
|
describe "check_box accessors" do
|
320
354
|
context "when called on a page object" do
|
321
355
|
it "should generate accessor methods" do
|
@@ -324,7 +358,7 @@ describe PageObject::Accessors do
|
|
324
358
|
watir_page_object.should respond_to :active_checked?
|
325
359
|
watir_page_object.should respond_to(:active_checkbox)
|
326
360
|
end
|
327
|
-
|
361
|
+
|
328
362
|
it "should call a block on the element method when present" do
|
329
363
|
block_page_object.active_checkbox.should == "checkbox"
|
330
364
|
end
|
@@ -348,7 +382,7 @@ describe PageObject::Accessors do
|
|
348
382
|
watir_browser.should_receive(:set?).and_return(true)
|
349
383
|
watir_page_object.active_checked?.should be_true
|
350
384
|
end
|
351
|
-
|
385
|
+
|
352
386
|
it "should retrieve a checkbox element" do
|
353
387
|
watir_browser.should_receive(:checkbox).and_return(watir_browser)
|
354
388
|
element = watir_page_object.active_checkbox
|
@@ -363,20 +397,20 @@ describe PageObject::Accessors do
|
|
363
397
|
selenium_browser.should_receive(:click)
|
364
398
|
selenium_page_object.check_active
|
365
399
|
end
|
366
|
-
|
400
|
+
|
367
401
|
it "should clear a check box element" do
|
368
402
|
selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
|
369
403
|
selenium_browser.should_receive(:selected?).and_return(true)
|
370
404
|
selenium_browser.should_receive(:click)
|
371
405
|
selenium_page_object.uncheck_active
|
372
406
|
end
|
373
|
-
|
407
|
+
|
374
408
|
it "should know if a check box element is selected" do
|
375
409
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
376
410
|
selenium_browser.should_receive(:selected?).and_return(true)
|
377
411
|
selenium_page_object.active_checked?.should be_true
|
378
412
|
end
|
379
|
-
|
413
|
+
|
380
414
|
it "should retrieve a checkbox element" do
|
381
415
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
382
416
|
element = selenium_page_object.active_checkbox
|
@@ -384,8 +418,8 @@ describe PageObject::Accessors do
|
|
384
418
|
end
|
385
419
|
end
|
386
420
|
end
|
387
|
-
|
388
|
-
|
421
|
+
|
422
|
+
|
389
423
|
describe "radio accessors" do
|
390
424
|
context "when called on a page object" do
|
391
425
|
it "should generate accessor methods" do
|
@@ -394,7 +428,7 @@ describe PageObject::Accessors do
|
|
394
428
|
watir_page_object.should respond_to :first_selected?
|
395
429
|
watir_page_object.should respond_to(:first_radio_button)
|
396
430
|
end
|
397
|
-
|
431
|
+
|
398
432
|
it "should call a block on the element method when present" do
|
399
433
|
block_page_object.first_radio_button.should == "radio_button"
|
400
434
|
end
|
@@ -406,19 +440,19 @@ describe PageObject::Accessors do
|
|
406
440
|
watir_browser.should_receive(:set)
|
407
441
|
watir_page_object.select_first
|
408
442
|
end
|
409
|
-
|
443
|
+
|
410
444
|
it "should clear a radio button" do
|
411
445
|
watir_browser.should_receive(:radio).and_return(watir_browser)
|
412
446
|
watir_browser.should_receive(:clear)
|
413
447
|
watir_page_object.clear_first
|
414
448
|
end
|
415
|
-
|
449
|
+
|
416
450
|
it "should determine if a radio is selected" do
|
417
451
|
watir_browser.should_receive(:radio).and_return(watir_browser)
|
418
452
|
watir_browser.should_receive(:set?)
|
419
453
|
watir_page_object.first_selected?
|
420
454
|
end
|
421
|
-
|
455
|
+
|
422
456
|
it "should retrieve a radio button element" do
|
423
457
|
watir_browser.should_receive(:radio).and_return(watir_browser)
|
424
458
|
element = watir_page_object.first_radio_button
|
@@ -433,7 +467,7 @@ describe PageObject::Accessors do
|
|
433
467
|
selenium_browser.should_receive(:click)
|
434
468
|
selenium_page_object.select_first
|
435
469
|
end
|
436
|
-
|
470
|
+
|
437
471
|
it "should clear a radio button" do
|
438
472
|
selenium_browser.should_receive(:find_element).twice.and_return(selenium_browser)
|
439
473
|
selenium_browser.should_receive(:selected?).and_return(true)
|
@@ -446,7 +480,7 @@ describe PageObject::Accessors do
|
|
446
480
|
selenium_browser.should_receive(:selected?).and_return(true)
|
447
481
|
selenium_page_object.first_selected?
|
448
482
|
end
|
449
|
-
|
483
|
+
|
450
484
|
it "should retrieve a radio button element" do
|
451
485
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
452
486
|
element = selenium_page_object.first_radio_button
|
@@ -466,37 +500,37 @@ describe PageObject::Accessors do
|
|
466
500
|
block_page_object.click_me_button.should == "button"
|
467
501
|
end
|
468
502
|
end
|
469
|
-
|
503
|
+
|
470
504
|
context "watir implementation" do
|
471
505
|
it "should be able to click a button" do
|
472
506
|
watir_browser.should_receive(:button).and_return(watir_browser)
|
473
507
|
watir_browser.should_receive(:click)
|
474
508
|
watir_page_object.click_me
|
475
509
|
end
|
476
|
-
|
510
|
+
|
477
511
|
it "should retrieve a button element" do
|
478
512
|
watir_browser.should_receive(:button).and_return(watir_browser)
|
479
513
|
element = watir_page_object.click_me_button
|
480
514
|
element.should be_instance_of PageObject::Elements::Button
|
481
515
|
end
|
482
516
|
end
|
483
|
-
|
517
|
+
|
484
518
|
context "selenium implementation" do
|
485
519
|
it "should be able to click a button" do
|
486
520
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
487
521
|
selenium_browser.should_receive(:click)
|
488
522
|
selenium_page_object.click_me
|
489
523
|
end
|
490
|
-
|
524
|
+
|
491
525
|
it "should retrieve a button element" do
|
492
526
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
493
527
|
element = selenium_page_object.click_me_button
|
494
528
|
element.should be_instance_of PageObject::Elements::Button
|
495
|
-
|
529
|
+
|
496
530
|
end
|
497
531
|
end
|
498
532
|
end
|
499
|
-
|
533
|
+
|
500
534
|
describe "div accessors" do
|
501
535
|
context "when called on a page object" do
|
502
536
|
it "should generate accessor methods" do
|
@@ -508,38 +542,38 @@ describe PageObject::Accessors do
|
|
508
542
|
block_page_object.footer_div.should == "div"
|
509
543
|
end
|
510
544
|
end
|
511
|
-
|
545
|
+
|
512
546
|
context "watir implementation" do
|
513
547
|
it "should retrieve the text from a div" do
|
514
548
|
watir_browser.should_receive(:div).and_return(watir_browser)
|
515
549
|
watir_browser.should_receive(:text).and_return("Message from div")
|
516
550
|
watir_page_object.message.should == "Message from div"
|
517
551
|
end
|
518
|
-
|
552
|
+
|
519
553
|
it "should retrieve the div element from the page" do
|
520
554
|
watir_browser.should_receive(:div).and_return(watir_browser)
|
521
555
|
element = watir_page_object.message_div
|
522
556
|
element.should be_instance_of PageObject::Elements::Div
|
523
557
|
end
|
524
558
|
end
|
525
|
-
|
559
|
+
|
526
560
|
context "selenium implementation" do
|
527
561
|
it "should retrieve the text from a div" do
|
528
562
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
529
563
|
selenium_browser.should_receive(:text).and_return("Message from div")
|
530
564
|
selenium_page_object.message.should == "Message from div"
|
531
|
-
|
565
|
+
|
532
566
|
end
|
533
|
-
|
567
|
+
|
534
568
|
it "should retrieve the div element from the page" do
|
535
569
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
536
570
|
element = selenium_page_object.message_div
|
537
571
|
element.should be_instance_of PageObject::Elements::Div
|
538
|
-
|
572
|
+
|
539
573
|
end
|
540
574
|
end
|
541
575
|
end
|
542
|
-
|
576
|
+
|
543
577
|
describe "span accessors" do
|
544
578
|
context "when called on a page object" do
|
545
579
|
it "should generate accessor methods" do
|
@@ -551,48 +585,48 @@ describe PageObject::Accessors do
|
|
551
585
|
block_page_object.alert_span.should == "span"
|
552
586
|
end
|
553
587
|
end
|
554
|
-
|
588
|
+
|
555
589
|
context "watir implementation" do
|
556
590
|
it "should retrieve the text from a span" do
|
557
591
|
watir_browser.should_receive(:span).and_return(watir_browser)
|
558
592
|
watir_browser.should_receive(:text).and_return("Alert")
|
559
593
|
watir_page_object.alert.should == "Alert"
|
560
594
|
end
|
561
|
-
|
595
|
+
|
562
596
|
it "should retrieve the span element from the page" do
|
563
597
|
watir_browser.should_receive(:span).and_return(watir_browser)
|
564
598
|
element = watir_page_object.alert_span
|
565
599
|
element.should be_instance_of PageObject::Elements::Span
|
566
600
|
end
|
567
601
|
end
|
568
|
-
|
602
|
+
|
569
603
|
context "selenium implementation" do
|
570
604
|
it "should retrieve the text from a span" do
|
571
605
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
572
606
|
selenium_browser.should_receive(:text).and_return("Alert")
|
573
607
|
selenium_page_object.alert.should == "Alert"
|
574
608
|
end
|
575
|
-
|
609
|
+
|
576
610
|
it "should retrieve the span element from the page" do
|
577
611
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
578
612
|
element = selenium_page_object.alert_span
|
579
613
|
element.should be_instance_of PageObject::Elements::Span
|
580
|
-
|
614
|
+
|
581
615
|
end
|
582
616
|
end
|
583
617
|
end
|
584
|
-
|
618
|
+
|
585
619
|
describe "table accessors" do
|
586
620
|
context "when called on a page object" do
|
587
621
|
it "should generate accessor methods" do
|
588
622
|
watir_page_object.should respond_to(:cart_table)
|
589
623
|
end
|
590
|
-
|
624
|
+
|
591
625
|
it "should call a block on the element method when present" do
|
592
626
|
block_page_object.cart_table.should == "table"
|
593
627
|
end
|
594
628
|
end
|
595
|
-
|
629
|
+
|
596
630
|
context "watir implementation" do
|
597
631
|
it "should retrieve the table element from the page" do
|
598
632
|
watir_browser.should_receive(:table).and_return(watir_browser)
|
@@ -600,7 +634,7 @@ describe PageObject::Accessors do
|
|
600
634
|
element.should be_instance_of PageObject::Elements::Table
|
601
635
|
end
|
602
636
|
end
|
603
|
-
|
637
|
+
|
604
638
|
context "selenium implementation" do
|
605
639
|
it "should retrieve the table element from the page" do
|
606
640
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
@@ -609,7 +643,7 @@ describe PageObject::Accessors do
|
|
609
643
|
end
|
610
644
|
end
|
611
645
|
end
|
612
|
-
|
646
|
+
|
613
647
|
describe "table cell accessors" do
|
614
648
|
context "when called on a page object" do
|
615
649
|
it "should generate accessor methods" do
|
@@ -621,21 +655,21 @@ describe PageObject::Accessors do
|
|
621
655
|
block_page_object.total_cell.should == "cell"
|
622
656
|
end
|
623
657
|
end
|
624
|
-
|
658
|
+
|
625
659
|
context "watir implementation" do
|
626
660
|
it "should retrieve the text for the cell" do
|
627
661
|
watir_browser.should_receive(:td).and_return(watir_browser)
|
628
662
|
watir_browser.should_receive(:text).and_return('10.00')
|
629
663
|
watir_page_object.total.should == '10.00'
|
630
664
|
end
|
631
|
-
|
665
|
+
|
632
666
|
it "should retrieve the cell element from the page" do
|
633
667
|
watir_browser.should_receive(:td).and_return(watir_browser)
|
634
668
|
element = watir_page_object.total_cell
|
635
669
|
element.should be_instance_of PageObject::Elements::TableCell
|
636
670
|
end
|
637
671
|
end
|
638
|
-
|
672
|
+
|
639
673
|
context "selenium implementation" do
|
640
674
|
it "should retrieve the text from the cell" do
|
641
675
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
@@ -644,7 +678,7 @@ describe PageObject::Accessors do
|
|
644
678
|
end
|
645
679
|
end
|
646
680
|
end
|
647
|
-
|
681
|
+
|
648
682
|
describe "image accessors" do
|
649
683
|
context "when called on a page object" do
|
650
684
|
it "should generate accessor methods" do
|
@@ -655,7 +689,7 @@ describe PageObject::Accessors do
|
|
655
689
|
block_page_object.logo_image.should == "image"
|
656
690
|
end
|
657
691
|
end
|
658
|
-
|
692
|
+
|
659
693
|
context "watir implementation" do
|
660
694
|
it "should retrieve the image element from the page" do
|
661
695
|
watir_browser.should_receive(:image).and_return(watir_browser)
|
@@ -663,7 +697,7 @@ describe PageObject::Accessors do
|
|
663
697
|
element.should be_instance_of PageObject::Elements::Image
|
664
698
|
end
|
665
699
|
end
|
666
|
-
|
700
|
+
|
667
701
|
context "selenium implementation" do
|
668
702
|
it "should retrieve the image element from the page" do
|
669
703
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
@@ -672,7 +706,7 @@ describe PageObject::Accessors do
|
|
672
706
|
end
|
673
707
|
end
|
674
708
|
end
|
675
|
-
|
709
|
+
|
676
710
|
describe "form accessors" do
|
677
711
|
context "when called on a page object" do
|
678
712
|
it "should generate accessor methods" do
|
@@ -683,7 +717,7 @@ describe PageObject::Accessors do
|
|
683
717
|
block_page_object.login_form.should == "form"
|
684
718
|
end
|
685
719
|
end
|
686
|
-
|
720
|
+
|
687
721
|
context "watir implementation" do
|
688
722
|
it "should retrieve the form element from the page" do
|
689
723
|
watir_browser.should_receive(:form).and_return(watir_browser)
|
@@ -691,7 +725,7 @@ describe PageObject::Accessors do
|
|
691
725
|
element.should be_instance_of PageObject::Elements::Form
|
692
726
|
end
|
693
727
|
end
|
694
|
-
|
728
|
+
|
695
729
|
context "selenium implementation" do
|
696
730
|
it "should retrieve the form element from the page" do
|
697
731
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
@@ -700,7 +734,7 @@ describe PageObject::Accessors do
|
|
700
734
|
end
|
701
735
|
end
|
702
736
|
end
|
703
|
-
|
737
|
+
|
704
738
|
describe "list item accessors" do
|
705
739
|
context "when called on a page object" do
|
706
740
|
it "should generate accessor methods" do
|
@@ -712,28 +746,28 @@ describe PageObject::Accessors do
|
|
712
746
|
block_page_object.item_one_list_item.should == "list_item"
|
713
747
|
end
|
714
748
|
end
|
715
|
-
|
749
|
+
|
716
750
|
context "watir implementation" do
|
717
751
|
it "should retrieve the text from the list item" do
|
718
752
|
watir_browser.should_receive(:li).and_return(watir_browser)
|
719
753
|
watir_browser.should_receive(:text).and_return("value")
|
720
754
|
watir_page_object.item_one.should == "value"
|
721
755
|
end
|
722
|
-
|
756
|
+
|
723
757
|
it "should retrieve the list item element from the page" do
|
724
758
|
watir_browser.should_receive(:li).and_return(watir_browser)
|
725
759
|
element = watir_page_object.item_one_list_item
|
726
760
|
element.should be_instance_of PageObject::Elements::ListItem
|
727
761
|
end
|
728
762
|
end
|
729
|
-
|
763
|
+
|
730
764
|
context "selenium implementation" do
|
731
765
|
it "should retrieve the text from the list item" do
|
732
766
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
733
767
|
selenium_browser.should_receive(:text).and_return("value")
|
734
768
|
selenium_page_object.item_one.should == "value"
|
735
769
|
end
|
736
|
-
|
770
|
+
|
737
771
|
it "should retrieve the list item from the page" do
|
738
772
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
739
773
|
element = selenium_page_object.item_one_list_item
|
@@ -741,7 +775,7 @@ describe PageObject::Accessors do
|
|
741
775
|
end
|
742
776
|
end
|
743
777
|
end
|
744
|
-
|
778
|
+
|
745
779
|
describe "unordered list accessors" do
|
746
780
|
context "when called on a page object" do
|
747
781
|
it "should generate accessor methods" do
|
@@ -752,7 +786,7 @@ describe PageObject::Accessors do
|
|
752
786
|
block_page_object.menu_unordered_list.should == "unordered_list"
|
753
787
|
end
|
754
788
|
end
|
755
|
-
|
789
|
+
|
756
790
|
context "watir implementation" do
|
757
791
|
it "should retrieve the element from the page" do
|
758
792
|
watir_browser.should_receive(:ul).and_return(watir_browser)
|
@@ -760,7 +794,7 @@ describe PageObject::Accessors do
|
|
760
794
|
element.should be_instance_of PageObject::Elements::UnorderedList
|
761
795
|
end
|
762
796
|
end
|
763
|
-
|
797
|
+
|
764
798
|
context "selenium implementation" do
|
765
799
|
it "should retrieve the element from the page" do
|
766
800
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
@@ -769,7 +803,7 @@ describe PageObject::Accessors do
|
|
769
803
|
end
|
770
804
|
end
|
771
805
|
end
|
772
|
-
|
806
|
+
|
773
807
|
describe "ordered list accessors" do
|
774
808
|
context "when called on a page object" do
|
775
809
|
it "should generate accessor methods" do
|
@@ -780,7 +814,7 @@ describe PageObject::Accessors do
|
|
780
814
|
block_page_object.top_five_ordered_list.should == "ordered_list"
|
781
815
|
end
|
782
816
|
end
|
783
|
-
|
817
|
+
|
784
818
|
context "watir implementation" do
|
785
819
|
it "should retrieve the element from the page" do
|
786
820
|
watir_browser.should_receive(:ol).and_return(watir_browser)
|
@@ -788,7 +822,7 @@ describe PageObject::Accessors do
|
|
788
822
|
element.should be_instance_of PageObject::Elements::OrderedList
|
789
823
|
end
|
790
824
|
end
|
791
|
-
|
825
|
+
|
792
826
|
context "selenium implementation" do
|
793
827
|
it "should retrieve the element from the page" do
|
794
828
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|