page-object 0.6.6 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -1
- data/ChangeLog +13 -0
- data/README.md +3 -0
- data/Rakefile +1 -1
- data/features/async.feature +7 -0
- data/features/element.feature +4 -0
- data/features/html/async.html +8 -1
- data/features/sample-app/sample_app.rb +2 -3
- data/features/step_definitions/async_steps.rb +11 -0
- data/features/step_definitions/element_steps.rb +4 -0
- data/features/step_definitions/table_steps.rb +11 -2
- data/features/support/ajax_text_environment.rb +1 -1
- data/features/support/hooks.rb +1 -0
- data/features/table.feature +12 -0
- data/lib/page-object.rb +29 -1
- data/lib/page-object/elements/table_cell.rb +7 -0
- data/lib/page-object/platforms/selenium_webdriver/element.rb +37 -6
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +4 -1
- data/lib/page-object/platforms/selenium_webdriver/select_list.rb +3 -1
- data/lib/page-object/platforms/selenium_webdriver/table.rb +10 -1
- data/lib/page-object/platforms/selenium_webdriver/table_row.rb +10 -2
- data/lib/page-object/platforms/watir_webdriver/element.rb +21 -4
- data/lib/page-object/platforms/watir_webdriver/table.rb +9 -1
- data/lib/page-object/platforms/watir_webdriver/table_row.rb +12 -2
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +4 -4
- data/spec/page-object/accessors_spec.rb +4 -1
- data/spec/page-object/elements/select_list_spec.rb +4 -1
- data/spec/page-object/elements/selenium_element_spec.rb +15 -0
- data/spec/page-object/elements/table_cell_spec.rb +6 -0
- data/spec/page-object/elements/watir_element_spec.rb +7 -0
- data/spec/page-object/page-object_spec.rb +6 -0
- metadata +17 -17
data/.travis.yml
CHANGED
data/ChangeLog
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
=== Version 0.6.7 / 2012-5-16
|
2
|
+
* Enhancements
|
3
|
+
* Added flash method to Element to temporarily change the background color
|
4
|
+
* Added when_not_present method to Element
|
5
|
+
* Added default override for page level waits - PageObject.default_page_wait
|
6
|
+
* Added default override for element level waits - PageObject.default_element_wait
|
7
|
+
* Added the ability to find a TableRow by providing a String to the [] method from Table
|
8
|
+
* Added the ability to find a TableCell by providing a String to the [] method from TableRow
|
9
|
+
* Updated to use watir-webdriver 0.5.8
|
10
|
+
* Fixes
|
11
|
+
* Improved logic around selecting options from select lists
|
12
|
+
* TableCell now handles enabled? call gracefully
|
13
|
+
|
1
14
|
=== Version 0.6.6 / 2012-4-26
|
2
15
|
* Enhancements
|
3
16
|
* Added ability to find span's by title
|
data/README.md
CHANGED
@@ -15,6 +15,9 @@ 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
|
+
## Support
|
19
|
+
|
20
|
+
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).
|
18
21
|
|
19
22
|
## Basic Usage
|
20
23
|
|
data/Rakefile
CHANGED
data/features/async.feature
CHANGED
@@ -21,3 +21,10 @@ Feature: Handling Asynch calls
|
|
21
21
|
Given I am on the async elements page
|
22
22
|
When I add a button a few seconds from now
|
23
23
|
Then I should be able to click it when it gets added
|
24
|
+
|
25
|
+
Scenario: Wait for an element to disappear from the page
|
26
|
+
Given I am on the async elements page
|
27
|
+
When I add a button a few seconds from now
|
28
|
+
And I remove a button a few seconds from now
|
29
|
+
Then I should not be able to find the button
|
30
|
+
|
data/features/element.feature
CHANGED
data/features/html/async.html
CHANGED
@@ -13,9 +13,15 @@
|
|
13
13
|
function addDiv() {
|
14
14
|
var button = document.createElement("input");
|
15
15
|
button.setAttribute("type", "button");
|
16
|
-
button.setAttribute("value", "New Button")
|
16
|
+
button.setAttribute("value", "New Button");
|
17
|
+
button.setAttribute("id", "new_button");
|
17
18
|
document.body.appendChild(button);
|
18
19
|
}
|
20
|
+
|
21
|
+
function removeDiv() {
|
22
|
+
var button = document.getElementById("new_button");
|
23
|
+
document.body.removeChild(button);
|
24
|
+
}
|
19
25
|
</script>
|
20
26
|
</head>
|
21
27
|
<body>
|
@@ -23,6 +29,7 @@
|
|
23
29
|
<input type="button" onclick="setTimeout(function() {hide();}, 2000);" value="Hide Button"/>
|
24
30
|
<input type="button" onclick="setTimeout(function() {unhide();}, 2000);" value="Unhide Button"/>
|
25
31
|
<input type="button" onclick="setTimeout(function() {addDiv();}, 2000);" value="Create Button"/>
|
32
|
+
<input type="button" onclick="setTimeout(function() {removeDiv();}, 2000);" value="Remove Button"/>
|
26
33
|
</body>
|
27
34
|
</html>
|
28
35
|
|
@@ -6,11 +6,11 @@ require 'webrick'
|
|
6
6
|
class SampleApp
|
7
7
|
|
8
8
|
def self.start(host, port)
|
9
|
-
Rack::Handler::WEBrick.run
|
9
|
+
Rack::Handler::WEBrick.run new,
|
10
10
|
:Host => host,
|
11
11
|
:Port => port,
|
12
12
|
:Logger => ::WEBrick::Log.new('/dev/null'),
|
13
|
-
:AccessLog => [nil, nil]
|
13
|
+
:AccessLog => [nil, nil]
|
14
14
|
end
|
15
15
|
|
16
16
|
def initialize
|
@@ -33,4 +33,3 @@ class SampleApp
|
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
36
|
-
|
@@ -36,6 +36,7 @@ class AsyncPage
|
|
36
36
|
button(:hide, :value => 'Hide Button')
|
37
37
|
button(:unhide, :value => 'Unhide Button')
|
38
38
|
button(:create_button, :value => 'Create Button')
|
39
|
+
button(:remove_button, :value => 'Remove Button')
|
39
40
|
button(:created_button, :value => 'New Button')
|
40
41
|
end
|
41
42
|
|
@@ -70,3 +71,13 @@ end
|
|
70
71
|
Then /^I should be able to click it when it gets added$/ do
|
71
72
|
@page.created_button_element.when_present.click
|
72
73
|
end
|
74
|
+
|
75
|
+
When /^I remove a button a few seconds from now$/ do
|
76
|
+
@page.created_button_element.when_present
|
77
|
+
@page.remove_button
|
78
|
+
end
|
79
|
+
|
80
|
+
Then /^I should not be able to find the button$/ do
|
81
|
+
@page.created_button_element.when_not_present
|
82
|
+
@page.created_button_element.exists?.should be_false
|
83
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
Then /^the data for row "([^\"]*)" should be "([^\"]*)" and "([^\"]*)"$/ do |row, col1, col2|
|
2
|
-
|
2
|
+
row = (row.to_i - 1) if row.to_i > 0
|
3
|
+
table_row = @element[row]
|
3
4
|
table_row[0].text.should == col1
|
4
5
|
table_row[1].text.should == col2
|
5
6
|
end
|
@@ -37,4 +38,12 @@ end
|
|
37
38
|
|
38
39
|
Then /^I should see that the table exists$/ do
|
39
40
|
@page.table_id?.should == true
|
40
|
-
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Then /^the data for column "([^\"]*)" and row "([^\"]*)" should be "([^\"]*)"$/ do |column, row, value|
|
44
|
+
@element[row.to_i - 1][column].text.should == value
|
45
|
+
end
|
46
|
+
|
47
|
+
Then /^the data for row "([^\"]*)" and column "([^\"]*)" should be "([^\"]*)"$/ do |row, column, value|
|
48
|
+
@element[row][column].text.should == value
|
49
|
+
end
|
data/features/support/hooks.rb
CHANGED
data/features/table.feature
CHANGED
@@ -25,6 +25,18 @@ Feature: Table
|
|
25
25
|
And each column should contain "Data"
|
26
26
|
And the data for the first row should be "Data1" and "Data2"
|
27
27
|
And the data for the last row should be "Data3" and "Data4"
|
28
|
+
|
29
|
+
Scenario: Retrieve data from a table using the row header
|
30
|
+
When I retrieve a table element
|
31
|
+
Then the data for row "Data3" should be "Data3" and "Data4"
|
32
|
+
|
33
|
+
Scenario: Retrieve data from a table using a column header
|
34
|
+
When I retrieve a table element
|
35
|
+
Then the data for column "Data2" and row "2" should be "Data4"
|
36
|
+
|
37
|
+
Scenario: Retrieve data from a table using both headers
|
38
|
+
When I retrieve a table element
|
39
|
+
Then the data for row "Data3" and column "Data2" should be "Data4"
|
28
40
|
|
29
41
|
Scenario Outline: Locating table cells on the Page
|
30
42
|
When I retrieve a table element by "<search_by>"
|
data/lib/page-object.rb
CHANGED
@@ -64,6 +64,34 @@ module PageObject
|
|
64
64
|
cls.extend PageObject::Accessors
|
65
65
|
end
|
66
66
|
|
67
|
+
#
|
68
|
+
# Set the default timeout for page level waits
|
69
|
+
#
|
70
|
+
def self.default_page_wait=(timeout)
|
71
|
+
@page_wait = timeout
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Returns the default timeout for page lavel waits
|
76
|
+
#
|
77
|
+
def self.default_page_wait
|
78
|
+
@page_wait ||= 30
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Sets the default timeout for element level waits
|
83
|
+
#
|
84
|
+
def self.default_element_wait=(timeout)
|
85
|
+
@element_wait = timeout
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# Returns the default timeout for element level waits
|
90
|
+
#
|
91
|
+
def self.default_element_wait
|
92
|
+
@element_wait ||= 5
|
93
|
+
end
|
94
|
+
|
67
95
|
#
|
68
96
|
# Set the javascript framework to use when determining number of
|
69
97
|
# ajax requests. Valid frameworks are :jquery and :prototype
|
@@ -135,7 +163,7 @@ module PageObject
|
|
135
163
|
# @param [String] the message to include with the error if we exceed the timeout duration.
|
136
164
|
# @param block the block to execute. It should return true when successful.
|
137
165
|
#
|
138
|
-
def wait_until(timeout =
|
166
|
+
def wait_until(timeout = PageObject.default_page_wait, message = nil, &block)
|
139
167
|
platform.wait_until(timeout, message, &block)
|
140
168
|
end
|
141
169
|
|
@@ -23,6 +23,18 @@ module PageObject
|
|
23
23
|
not element.nil?
|
24
24
|
end
|
25
25
|
|
26
|
+
#
|
27
|
+
# flash the element by temporarily changing the background color
|
28
|
+
#
|
29
|
+
def flash
|
30
|
+
original_color = attribute('backgroundColor')
|
31
|
+
bridge = element.instance_variable_get(:@bridge)
|
32
|
+
10.times do |n|
|
33
|
+
color = (n % 2 == 0) ? 'red' : original_color
|
34
|
+
bridge.executeScript("arguments[0].style.backgroundColor = '#{color}'", element)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
26
38
|
#
|
27
39
|
# Get the text for the element
|
28
40
|
#
|
@@ -133,7 +145,7 @@ module PageObject
|
|
133
145
|
#
|
134
146
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
135
147
|
#
|
136
|
-
def when_present(timeout
|
148
|
+
def when_present(timeout=::PageObject.default_element_wait)
|
137
149
|
wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element not present in #{timeout} seconds"})
|
138
150
|
wait.until do
|
139
151
|
self.exists?
|
@@ -141,13 +153,32 @@ module PageObject
|
|
141
153
|
self
|
142
154
|
end
|
143
155
|
|
156
|
+
#
|
157
|
+
# Waits until the element is not present
|
158
|
+
#
|
159
|
+
# @param [Integer] (defaults to: 5) seconds to wait before
|
160
|
+
# timing out
|
161
|
+
#
|
162
|
+
def when_not_present(timeout=::PageObject.default_element_wait)
|
163
|
+
wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element still present in #{timeout} seconds"})
|
164
|
+
wait.until do
|
165
|
+
not_present = false
|
166
|
+
begin
|
167
|
+
not_present = false if element and element.displayed?
|
168
|
+
rescue Selenium::WebDriver::Error::ObsoleteElementError
|
169
|
+
not_present = true
|
170
|
+
end
|
171
|
+
not_present
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
144
175
|
#
|
145
176
|
# Waits until the element is visible
|
146
177
|
#
|
147
178
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
148
179
|
#
|
149
|
-
def when_visible(timeout
|
150
|
-
wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element not
|
180
|
+
def when_visible(timeout=::PageObject.default_element_wait)
|
181
|
+
wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element not visible in #{timeout} seconds"})
|
151
182
|
wait.until do
|
152
183
|
self.visible?
|
153
184
|
end
|
@@ -159,8 +190,8 @@ module PageObject
|
|
159
190
|
#
|
160
191
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
161
192
|
#
|
162
|
-
def when_not_visible(timeout
|
163
|
-
wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element
|
193
|
+
def when_not_visible(timeout=::PageObject.default_element_wait)
|
194
|
+
wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Element still visible in #{timeout} seconds"})
|
164
195
|
wait.until do
|
165
196
|
not self.visible?
|
166
197
|
end
|
@@ -174,7 +205,7 @@ module PageObject
|
|
174
205
|
# @param [String] the message to display if the event timeouts
|
175
206
|
# @param the block to execute when the event occurrs
|
176
207
|
#
|
177
|
-
def wait_until(timeout
|
208
|
+
def wait_until(timeout=::PageObject.default_element_wait, message=nil, &block)
|
178
209
|
wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => message})
|
179
210
|
wait.until &block
|
180
211
|
end
|
@@ -297,7 +297,10 @@ module PageObject
|
|
297
297
|
#
|
298
298
|
def select_list_value_set(identifier, value)
|
299
299
|
process_selenium_call(identifier, Elements::SelectList, 'select') do |how, what|
|
300
|
-
@browser.find_element(how, what)
|
300
|
+
select_list = @browser.find_element(how, what)
|
301
|
+
select_list.find_elements(:tag_name => 'option').find do |option|
|
302
|
+
option.text == value
|
303
|
+
end.click
|
301
304
|
end
|
302
305
|
end
|
303
306
|
|
@@ -5,12 +5,14 @@ module PageObject
|
|
5
5
|
|
6
6
|
#
|
7
7
|
# Return the PageObject::Elements::TableRow for the index provided. Index
|
8
|
-
# is zero based.
|
8
|
+
# is zero based. If the index provided is a String then it
|
9
|
+
# will be matched with the text from the first column.
|
9
10
|
#
|
10
11
|
# @return [PageObject::Elements::TableRow]
|
11
12
|
#
|
12
13
|
def [](idx)
|
13
14
|
eles = table_rows
|
15
|
+
idx = find_index_by_title(idx, eles) if idx.kind_of?(String)
|
14
16
|
Object::PageObject::Elements::TableRow.new(eles[idx], :platform => :selenium_webdriver)
|
15
17
|
end
|
16
18
|
|
@@ -31,6 +33,13 @@ module PageObject
|
|
31
33
|
|
32
34
|
private
|
33
35
|
|
36
|
+
def find_index_by_title(row_title, eles)
|
37
|
+
eles.find_index do |row|
|
38
|
+
columns = row.find_elements(:xpath, ".//child::td|th")
|
39
|
+
columns.first.text == row_title
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
34
43
|
def table_rows
|
35
44
|
element.find_elements(:xpath, child_xpath)
|
36
45
|
end
|
@@ -6,10 +6,12 @@ module PageObject
|
|
6
6
|
|
7
7
|
#
|
8
8
|
# Return the PageObject::Elements::TableCell for the index provided. Index
|
9
|
-
# is zero based.
|
9
|
+
# is zero based. If the index provided is a String then it
|
10
|
+
# will be matched with the text from the columns in the first row.
|
10
11
|
#
|
11
12
|
def [](idx)
|
12
13
|
els = table_cells
|
14
|
+
idx = find_index_by_title(idx) if idx.kind_of?(String)
|
13
15
|
Object::PageObject::Elements::TableCell.new(els[idx], :platform => :selenium_webdriver)
|
14
16
|
end
|
15
17
|
|
@@ -22,6 +24,12 @@ module PageObject
|
|
22
24
|
|
23
25
|
private
|
24
26
|
|
27
|
+
def find_index_by_title(title)
|
28
|
+
table = parent
|
29
|
+
table = table.parent if parent.element.tag_name == 'tbody'
|
30
|
+
table[0].find_index {|column| column.text == title}
|
31
|
+
end
|
32
|
+
|
25
33
|
def table_cells
|
26
34
|
element.find_elements(:xpath, child_xpath)
|
27
35
|
end
|
@@ -29,4 +37,4 @@ module PageObject
|
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
32
|
-
end
|
40
|
+
end
|
@@ -20,6 +20,13 @@ module PageObject
|
|
20
20
|
element.exists?
|
21
21
|
end
|
22
22
|
|
23
|
+
#
|
24
|
+
# flash the element by temporarily changing the background color
|
25
|
+
#
|
26
|
+
def flash
|
27
|
+
element.flash
|
28
|
+
end
|
29
|
+
|
23
30
|
#
|
24
31
|
# Get the text for the element
|
25
32
|
#
|
@@ -117,17 +124,27 @@ module PageObject
|
|
117
124
|
#
|
118
125
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
119
126
|
#
|
120
|
-
def when_present(timeout
|
127
|
+
def when_present(timeout=::PageObject.default_element_wait)
|
121
128
|
element.wait_until_present(timeout)
|
122
129
|
self
|
123
130
|
end
|
124
131
|
|
132
|
+
#
|
133
|
+
# Waits until the element is not present
|
134
|
+
#
|
135
|
+
# @param [Integer] (defaults to: 5) seconds to wait before
|
136
|
+
# timing out
|
137
|
+
#
|
138
|
+
def when_not_present(timeout=::PageObject.default_element_wait)
|
139
|
+
element.wait_while_present(timeout)
|
140
|
+
end
|
141
|
+
|
125
142
|
#
|
126
143
|
# Waits until the element is visible
|
127
144
|
#
|
128
145
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
129
146
|
#
|
130
|
-
def when_visible(timeout
|
147
|
+
def when_visible(timeout=::PageObject.default_element_wait)
|
131
148
|
Object::Watir::Wait.until(timeout, "Element was not visible in #{timeout} seconds") do
|
132
149
|
visible?
|
133
150
|
end
|
@@ -139,7 +156,7 @@ module PageObject
|
|
139
156
|
#
|
140
157
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
141
158
|
#
|
142
|
-
def when_not_visible(timeout
|
159
|
+
def when_not_visible(timeout=::PageObject.default_element_wait)
|
143
160
|
Object::Watir::Wait.while(timeout, "Element still visible after #{timeout} seconds") do
|
144
161
|
visible?
|
145
162
|
end
|
@@ -153,7 +170,7 @@ module PageObject
|
|
153
170
|
# @param [String] the message to display if the event timeouts
|
154
171
|
# @param the block to execute when the event occurrs
|
155
172
|
#
|
156
|
-
def wait_until(timeout
|
173
|
+
def wait_until(timeout=::PageObject.default_element_wait, message=nil, &block)
|
157
174
|
Object::Watir::Wait.until(timeout, message, &block)
|
158
175
|
end
|
159
176
|
|
@@ -6,11 +6,13 @@ module PageObject
|
|
6
6
|
|
7
7
|
#
|
8
8
|
# Return the PageObject::Elements::TableRow for the index provided. Index
|
9
|
-
# is zero based.
|
9
|
+
# is zero based. If the index provided is a String then it
|
10
|
+
# will be matched with the text from the first column.
|
10
11
|
#
|
11
12
|
# @return [PageObject::Elements::TableRow]
|
12
13
|
#
|
13
14
|
def [](idx)
|
15
|
+
idx = find_index_by_title(idx) if idx.kind_of?(String)
|
14
16
|
Object::PageObject::Elements::TableRow.new(element[idx], :platform => :watir_webdriver)
|
15
17
|
end
|
16
18
|
|
@@ -21,6 +23,12 @@ module PageObject
|
|
21
23
|
element.wd.find_elements(:xpath, child_xpath).size
|
22
24
|
end
|
23
25
|
|
26
|
+
private
|
27
|
+
|
28
|
+
def find_index_by_title(row_title)
|
29
|
+
element.rows.find_index {|row| row[0].text == row_title}
|
30
|
+
end
|
31
|
+
|
24
32
|
end
|
25
33
|
end
|
26
34
|
end
|
@@ -5,9 +5,11 @@ module PageObject
|
|
5
5
|
|
6
6
|
#
|
7
7
|
# Return the PageObject::Elements::TableCell for the index provided. Index
|
8
|
-
# is zero based.
|
8
|
+
# is zero based. If the index provided is a String then it
|
9
|
+
# will be matched with the text from the columns in the first row.
|
9
10
|
#
|
10
11
|
def [](idx)
|
12
|
+
idx = find_index_by_title(idx) if idx.kind_of?(String)
|
11
13
|
Object::PageObject::Elements::TableCell.new(element[idx], :platform => :watir_webdriver)
|
12
14
|
end
|
13
15
|
|
@@ -18,7 +20,15 @@ module PageObject
|
|
18
20
|
element.wd.find_elements(:xpath, child_xpath).size
|
19
21
|
end
|
20
22
|
|
23
|
+
private
|
24
|
+
|
25
|
+
def find_index_by_title(title)
|
26
|
+
table = element.parent
|
27
|
+
first_row = table[0]
|
28
|
+
first_row.cells.find_index {|column| column.text == title}
|
29
|
+
end
|
30
|
+
|
21
31
|
end
|
22
32
|
end
|
23
33
|
end
|
24
|
-
end
|
34
|
+
end
|
data/lib/page-object/version.rb
CHANGED
data/page-object.gemspec
CHANGED
@@ -19,11 +19,11 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency 'watir-webdriver', '>= 0.5.
|
23
|
-
s.add_dependency 'selenium-webdriver', '>= 2.21.2'
|
24
|
-
|
22
|
+
s.add_dependency 'watir-webdriver', '>= 0.5.8'
|
23
|
+
s.add_dependency 'selenium-webdriver', '>= 2.21.2'
|
24
|
+
|
25
25
|
s.add_development_dependency 'rspec', '>= 2.6.0'
|
26
|
-
s.add_development_dependency 'cucumber', '
|
26
|
+
s.add_development_dependency 'cucumber', '< 1.2.0'
|
27
27
|
s.add_development_dependency 'yard', '>= 0.7.2'
|
28
28
|
s.add_development_dependency 'rack', '>= 1.0'
|
29
29
|
|
@@ -607,8 +607,11 @@ describe PageObject::Accessors do
|
|
607
607
|
end
|
608
608
|
|
609
609
|
it "should set the current item of a select list" do
|
610
|
+
option = double('option')
|
610
611
|
selenium_browser.should_receive(:find_element).and_return(selenium_browser)
|
611
|
-
selenium_browser.should_receive(:
|
612
|
+
selenium_browser.should_receive(:find_elements).and_return([option])
|
613
|
+
option.should_receive(:text).and_return('OH')
|
614
|
+
option.should_receive(:click)
|
612
615
|
selenium_page_object.state = "OH"
|
613
616
|
end
|
614
617
|
|
@@ -83,7 +83,10 @@ describe PageObject::Elements::SelectList do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should select an element" do
|
86
|
-
|
86
|
+
option = double('option')
|
87
|
+
sel_list.should_receive(:find_elements).with(:xpath, ".//child::option").and_return([option])
|
88
|
+
option.should_receive(:text).and_return('something')
|
89
|
+
option.should_receive(:click)
|
87
90
|
selenium_sel_list.select 'something'
|
88
91
|
end
|
89
92
|
|
@@ -28,6 +28,14 @@ describe "Element for Selenium" do
|
|
28
28
|
@selenium_element.exists?.should == false
|
29
29
|
end
|
30
30
|
|
31
|
+
it "should flash an element" do
|
32
|
+
bridge = double('bridge')
|
33
|
+
@selenium_driver.should_receive(:attribute).and_return('blue')
|
34
|
+
@selenium_driver.should_receive(:instance_variable_get).and_return(bridge)
|
35
|
+
bridge.should_receive(:executeScript).exactly(10).times
|
36
|
+
@selenium_element.flash
|
37
|
+
end
|
38
|
+
|
31
39
|
it "should be able to return the text contained in the element" do
|
32
40
|
@selenium_driver.should_receive(:text).and_return("my text")
|
33
41
|
@selenium_element.text.should == "my text"
|
@@ -83,6 +91,13 @@ describe "Element for Selenium" do
|
|
83
91
|
element.should === @selenium_element
|
84
92
|
end
|
85
93
|
|
94
|
+
it "should return when an element is not present" do
|
95
|
+
wait = double('wait')
|
96
|
+
::Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
97
|
+
wait.should_receive(:until)
|
98
|
+
@selenium_element.when_not_present
|
99
|
+
end
|
100
|
+
|
86
101
|
it "should be able to block until it is visible" do
|
87
102
|
wait = double('wait')
|
88
103
|
::Selenium::WebDriver::Wait.should_receive(:new).and_return(wait)
|
@@ -11,5 +11,11 @@ describe PageObject::Elements::TableCell do
|
|
11
11
|
it "should register with tag_name :th" do
|
12
12
|
::PageObject::Elements.element_class_for(:th).should == ::PageObject::Elements::TableCell
|
13
13
|
end
|
14
|
+
|
15
|
+
it "should always be enabled" do
|
16
|
+
table_cell_element = double('table_cell_element')
|
17
|
+
table_cell = PageObject::Elements::TableCell.new(table_cell_element, :platform => :selenium_webdriver)
|
18
|
+
table_cell.enabled?.should be_true
|
19
|
+
end
|
14
20
|
end
|
15
21
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'page-object/elements/element'
|
2
3
|
|
3
4
|
describe "Element for Watir" do
|
4
5
|
let(:watir_driver) { double('watir_driver') }
|
@@ -81,6 +82,12 @@ describe "Element for Watir" do
|
|
81
82
|
element.should === watir_element
|
82
83
|
end
|
83
84
|
|
85
|
+
it "should use the overriden wait when set" do
|
86
|
+
PageObject.default_element_wait = 20
|
87
|
+
watir_driver.stub(:wait_until_present).with(20)
|
88
|
+
watir_element.when_present
|
89
|
+
end
|
90
|
+
|
84
91
|
it "should be able to block until it is visible" do
|
85
92
|
::Watir::Wait.stub(:until).with(10, "Element was not visible in 10 seconds")
|
86
93
|
watir_driver.stub(:displayed?).and_return(true)
|
@@ -110,6 +110,12 @@ describe PageObject do
|
|
110
110
|
watir_page_object.wait_until(5, "too long")
|
111
111
|
end
|
112
112
|
|
113
|
+
it "should use the overriden timeout value when set" do
|
114
|
+
PageObject.default_page_wait = 10
|
115
|
+
watir_browser.should_receive(:wait_until).with(10, nil)
|
116
|
+
watir_page_object.wait_until
|
117
|
+
end
|
118
|
+
|
113
119
|
it "should wait until there are no pending ajax requests" do
|
114
120
|
PageObject::JavascriptFrameworkFacade.should_receive(:pending_requests).and_return('pending requests')
|
115
121
|
watir_browser.should_receive(:execute_script).with('pending requests').and_return(0)
|
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.6.
|
4
|
+
version: 0.6.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &70136515814060 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.5.
|
21
|
+
version: 0.5.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70136515814060
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: selenium-webdriver
|
27
|
-
requirement: &
|
27
|
+
requirement: &70136515813300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.21.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70136515813300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70136515812620 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,21 +43,21 @@ dependencies:
|
|
43
43
|
version: 2.6.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70136515812620
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: cucumber
|
49
|
-
requirement: &
|
49
|
+
requirement: &70136515811900 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - <
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.2.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70136515811900
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: yard
|
60
|
-
requirement: &
|
60
|
+
requirement: &70136515811220 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.7.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70136515811220
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rack
|
71
|
-
requirement: &
|
71
|
+
requirement: &70136515810500 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '1.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70136515810500
|
80
80
|
description: Page Object DSL that works with both Watir and Selenium
|
81
81
|
email:
|
82
82
|
- jeff.morgan@leandog.com
|