page-object 2.1.1 → 2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/ChangeLog +14 -2
- data/Gemfile +0 -5
- data/lib/page-object.rb +6 -11
- data/lib/page-object/elements/button.rb +0 -11
- data/lib/page-object/elements/check_box.rb +0 -6
- data/lib/page-object/elements/div.rb +0 -7
- data/lib/page-object/elements/element.rb +13 -119
- data/lib/page-object/elements/file_field.rb +0 -6
- data/lib/page-object/elements/form.rb +0 -6
- data/lib/page-object/elements/hidden_field.rb +0 -6
- data/lib/page-object/elements/image.rb +0 -6
- data/lib/page-object/elements/label.rb +0 -6
- data/lib/page-object/elements/link.rb +0 -10
- data/lib/page-object/elements/list_item.rb +0 -6
- data/lib/page-object/elements/ordered_list.rb +2 -6
- data/lib/page-object/elements/radio_button.rb +0 -6
- data/lib/page-object/elements/select_list.rb +1 -5
- data/lib/page-object/elements/span.rb +0 -6
- data/lib/page-object/elements/table.rb +3 -3
- data/lib/page-object/elements/table_cell.rb +0 -6
- data/lib/page-object/elements/table_row.rb +3 -3
- data/lib/page-object/elements/text_area.rb +0 -6
- data/lib/page-object/elements/text_field.rb +0 -6
- data/lib/page-object/elements/unordered_list.rb +2 -6
- data/lib/page-object/indexed_properties.rb +2 -2
- data/lib/page-object/javascript_framework_facade.rb +1 -1
- data/lib/page-object/locator_generator.rb +152 -148
- data/lib/page-object/page_populator.rb +15 -0
- data/lib/page-object/platforms/watir.rb +3 -5
- data/lib/page-object/platforms/watir/page_object.rb +12 -20
- data/lib/page-object/version.rb +1 -1
- data/lib/page-object/widgets.rb +1 -13
- data/page-object.gemspec +6 -6
- metadata +27 -29
- data/lib/page-object/loads_platform.rb +0 -45
- data/lib/page-object/platforms.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a9026e5a1dfab04ad9562d3e2c1ff46224809d3
|
4
|
+
data.tar.gz: b64e10f88d26956b50be3feb5a41627f40dc2378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d780f2a594808da6f2bc24a6560c6a56bff7868600a6d025d91c98e68571c9bb85626c42a47a46983dd213ec9f84576f390f1dec987ee8dcc817d337131d1be7
|
7
|
+
data.tar.gz: 5af925dc3bcdf8d3bca259d53f4e88b75b258e7f0601004a02b8f55d533a82eebc25292c016dc5751bd488d303aef25fa96d0cd6dfc661a6c86a2833314733e5
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.4.0
|
data/ChangeLog
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
Version 2.2 / 2017-8-4
|
2
|
+
* Enhancements
|
3
|
+
* when_visible and when_not_visible now wait for element to be present before checking
|
4
|
+
* populate_page_with can populate select_list using values (Thanks vveliev)
|
5
|
+
* Removed all custom locator mappings
|
6
|
+
* Removed platform loading
|
7
|
+
* Fixes
|
8
|
+
* Moved net-http-persistent to a development dependency
|
9
|
+
* Fixed issue with frames, sections, and indexed properties
|
10
|
+
* Fixed issue impacting rspec be_visible/be_present DSL
|
11
|
+
* Fixed issue with getting content of empty multi-select
|
12
|
+
|
1
13
|
Version 2.1.1 / 2017-3-7
|
2
14
|
* Fixes
|
3
15
|
* Fixed issue with import ordering
|
@@ -60,7 +72,7 @@ Version 1.2.0 / 2016-6-15
|
|
60
72
|
|
61
73
|
=== Version 1.1.0 / 2015-5-2
|
62
74
|
* Enhancements
|
63
|
-
* Performance enhancements when initializing elements (Thanks
|
75
|
+
* Performance enhancements when initializing elements (Thanks Alexis Andersen)
|
64
76
|
* Enabled button elements to return text when using selenium-webdriver.
|
65
77
|
* Added support for :index identifier in indexed properties.
|
66
78
|
* Added page_section and page_sections accessor methods which can specify a page object of elements on another page object.
|
@@ -75,7 +87,7 @@ Version 1.2.0 / 2016-6-15
|
|
75
87
|
* Added hashes method to Table to return table contents as a Hash (Thanks Tobi)
|
76
88
|
* Fixed wait_for_expected_title so it detects if the title changes (Thanks Levi Wilson)
|
77
89
|
* Fixes
|
78
|
-
* Fixed issue that allows access to elements on other indexed properties (Thanks
|
90
|
+
* Fixed issue that allows access to elements on other indexed properties (Thanks Alexis Andersen)
|
79
91
|
* Removed the method to clear radio buttons. It didn't work on selenium and threw an exception on watir. (Thanks Justin Ko)
|
80
92
|
|
81
93
|
=== Version 1.0.2 / 2014-7-21
|
data/Gemfile
CHANGED
@@ -7,12 +7,7 @@ gem 'growl'
|
|
7
7
|
gem 'guard-rspec'
|
8
8
|
gem 'listen', '3.0.8' #Last version that supports ruby 2.0
|
9
9
|
gem 'guard-cucumber'
|
10
|
-
gem 'net-http-persistent'
|
11
10
|
gem 'coveralls', require: false
|
12
11
|
|
13
|
-
if ENV['WATIR_BRANCH']
|
14
|
-
gem 'watir', :git => 'https://github.com/watir/watir.git', :branch => ENV['WATIR_BRANCH']
|
15
|
-
end
|
16
|
-
|
17
12
|
|
18
13
|
gemspec
|
data/lib/page-object.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'watir'
|
2
2
|
require 'page-object/version'
|
3
3
|
require 'page-object/accessors'
|
4
|
-
require 'page-object/platforms'
|
5
4
|
require 'page-object/element_locators'
|
6
5
|
require 'page-object/nested_elements'
|
7
6
|
require 'page-object/page_factory'
|
@@ -11,6 +10,7 @@ require 'page-object/indexed_properties'
|
|
11
10
|
require 'page-object/section_collection'
|
12
11
|
require 'page-object/widgets'
|
13
12
|
|
13
|
+
require 'page-object/platforms/watir'
|
14
14
|
require 'page-object/platforms/watir/page_object'
|
15
15
|
|
16
16
|
#
|
@@ -42,7 +42,6 @@ require 'page-object/platforms/watir/page_object'
|
|
42
42
|
# @see PageObject::Accessors to see what class level methods are added to this module at runtime.
|
43
43
|
#
|
44
44
|
module PageObject
|
45
|
-
include LoadsPlatform
|
46
45
|
include ElementLocators
|
47
46
|
include PagePopulator
|
48
47
|
|
@@ -70,14 +69,14 @@ module PageObject
|
|
70
69
|
def initialize(root, visit=false)
|
71
70
|
initialize_accessors if respond_to?(:initialize_accessors)
|
72
71
|
initialize_browser(root)
|
73
|
-
goto if visit &&
|
72
|
+
goto if visit && self.class.instance_methods(false).include?(:goto)
|
74
73
|
initialize_page if respond_to?(:initialize_page)
|
75
74
|
end
|
76
75
|
|
77
76
|
def initialize_browser(root)
|
78
|
-
@root_element =
|
79
|
-
@browser =
|
80
|
-
|
77
|
+
@root_element = PageObject::Platforms::Watir.root_element_for root
|
78
|
+
@browser = root
|
79
|
+
@platform = PageObject::Platforms::Watir::PageObject.new @browser
|
81
80
|
end
|
82
81
|
|
83
82
|
# @private
|
@@ -412,11 +411,7 @@ module PageObject
|
|
412
411
|
private
|
413
412
|
|
414
413
|
def root
|
415
|
-
@root_element ||
|
416
|
-
end
|
417
|
-
|
418
|
-
def include_platform_driver(browser)
|
419
|
-
@platform = load_platform(browser, PageObject::Platforms.get)
|
414
|
+
@root_element || PageObject::Platforms::Watir.browser_root_for(browser)
|
420
415
|
end
|
421
416
|
|
422
417
|
def call_block(&block)
|
@@ -3,17 +3,6 @@ module PageObject
|
|
3
3
|
module Elements
|
4
4
|
class Button < Element
|
5
5
|
|
6
|
-
def initialize(element, platform)
|
7
|
-
@element = element
|
8
|
-
include_platform_for platform
|
9
|
-
end
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
def self.watir_finders
|
14
|
-
super + [:text, :value, :src, :alt, :css]
|
15
|
-
end
|
16
|
-
|
17
6
|
end
|
18
7
|
|
19
8
|
::PageObject::Elements.type_to_class[:submit] = ::PageObject::Elements::Button
|
@@ -6,16 +6,16 @@ module PageObject
|
|
6
6
|
#
|
7
7
|
# Contains functionality that is common across all elements.
|
8
8
|
#
|
9
|
-
# @see PageObject::Platforms::
|
9
|
+
# @see PageObject::Platforms::Watir::Element for the Watir version of all common methods
|
10
10
|
#
|
11
11
|
class Element
|
12
12
|
include ::PageObject::NestedElements
|
13
13
|
|
14
14
|
attr_reader :element
|
15
15
|
|
16
|
-
def initialize(element
|
16
|
+
def initialize(element)
|
17
17
|
@element = element
|
18
|
-
|
18
|
+
@platform = PageObject::Platforms::Watir::PageObject.new(@element)
|
19
19
|
end
|
20
20
|
|
21
21
|
#
|
@@ -42,8 +42,8 @@ module PageObject
|
|
42
42
|
#
|
43
43
|
def self.plural_form
|
44
44
|
"#{self.to_s.split('::')[-1].
|
45
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
46
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
45
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
46
|
+
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
47
47
|
tr("-", "_").
|
48
48
|
downcase}s"
|
49
49
|
end
|
@@ -125,7 +125,7 @@ module PageObject
|
|
125
125
|
parent = element.parent
|
126
126
|
type = element.type if parent.tag_name.to_sym == :input
|
127
127
|
cls = ::PageObject::Elements.element_class_for(parent.tag_name, type)
|
128
|
-
cls.new(parent
|
128
|
+
cls.new(parent)
|
129
129
|
end
|
130
130
|
|
131
131
|
#
|
@@ -134,7 +134,7 @@ module PageObject
|
|
134
134
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
135
135
|
#
|
136
136
|
def when_present(timeout=::PageObject.default_element_wait)
|
137
|
-
element.wait_until(timeout: timeout, message: "Element not present in #{timeout} seconds",
|
137
|
+
element.wait_until(timeout: timeout, message: "Element not present in #{timeout} seconds", &:present?)
|
138
138
|
self
|
139
139
|
end
|
140
140
|
|
@@ -154,6 +154,7 @@ module PageObject
|
|
154
154
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
155
155
|
#
|
156
156
|
def when_visible(timeout=::PageObject.default_element_wait)
|
157
|
+
when_present(timeout)
|
157
158
|
element.wait_until(timeout: timeout, message: "Element not visible in #{timeout} seconds", &:visible?)
|
158
159
|
self
|
159
160
|
end
|
@@ -164,7 +165,8 @@ module PageObject
|
|
164
165
|
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
165
166
|
#
|
166
167
|
def when_not_visible(timeout=::PageObject.default_element_wait)
|
167
|
-
|
168
|
+
when_present(timeout)
|
169
|
+
element.wait_while(timeout: timeout, message: "Element still visible after #{timeout} seconds", &:visible?)
|
168
170
|
end
|
169
171
|
|
170
172
|
#
|
@@ -222,22 +224,6 @@ module PageObject
|
|
222
224
|
{'y' => (location['y'] + (size['height']/2)), 'x' => (location['x'] + (size['width']/2))}
|
223
225
|
end
|
224
226
|
|
225
|
-
# @private
|
226
|
-
def self.watir_identifier_for identifier
|
227
|
-
if should_build_watir_xpath(identifier)
|
228
|
-
how = :xpath
|
229
|
-
what = build_xpath_for(identifier)
|
230
|
-
return how => what
|
231
|
-
end
|
232
|
-
all_identities = {}
|
233
|
-
identifier.each do |key, value|
|
234
|
-
each = {key => value}
|
235
|
-
ident = identifier_for each, watir_finders, watir_mapping
|
236
|
-
all_identities[ident.keys.first] = ident.values.first
|
237
|
-
end
|
238
|
-
all_identities
|
239
|
-
end
|
240
|
-
|
241
227
|
# @private
|
242
228
|
# delegate calls to driver element
|
243
229
|
def method_missing(*args, &block)
|
@@ -245,99 +231,11 @@ module PageObject
|
|
245
231
|
element.send m, *args, &block
|
246
232
|
end
|
247
233
|
|
248
|
-
|
249
|
-
|
250
|
-
def self.should_build_watir_xpath identifier
|
251
|
-
['table', 'span', 'div', 'td', 'li', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'label', 'area', 'canvas', 'audio', 'video', 'b', 'i'].include? identifier[:tag_name] and identifier[:name]
|
234
|
+
def respond_to_missing?(m,*args)
|
235
|
+
element.respond_to?(m) || super
|
252
236
|
end
|
253
237
|
|
254
|
-
|
255
|
-
tag_locator = identifier.delete(:tag_name)
|
256
|
-
idx = identifier.delete(:index)
|
257
|
-
if tag_locator == 'input' and identifier[:type] == 'submit'
|
258
|
-
identifier.delete(:type)
|
259
|
-
btn_ident = identifier.clone
|
260
|
-
if btn_ident[:value]
|
261
|
-
btn_ident[:text] = btn_ident[:value]
|
262
|
-
btn_ident.delete(:value)
|
263
|
-
end
|
264
|
-
xpath = ".//button"
|
265
|
-
xpath << "[#{attribute_expression(btn_ident)}]" unless btn_ident.empty?
|
266
|
-
xpath = "(#{xpath})[#{idx+1}]" if idx
|
267
|
-
identifier[:type] = %w[button reset submit image]
|
268
|
-
xpath << " | .//input"
|
269
|
-
else
|
270
|
-
xpath = ".//#{tag_locator}"
|
271
|
-
end
|
272
|
-
xpath << "[#{attribute_expression(identifier)}]" unless identifier.empty?
|
273
|
-
xpath = "(#{xpath})[#{idx+1}]" if idx
|
274
|
-
xpath
|
275
|
-
end
|
276
|
-
|
277
|
-
def self.attribute_expression(identifier)
|
278
|
-
identifier.map do |key, value|
|
279
|
-
if value.kind_of?(Array)
|
280
|
-
"(" + value.map { |v| equal_pair(key, v) }.join(" or ") + ")"
|
281
|
-
else
|
282
|
-
equal_pair(key, value)
|
283
|
-
end
|
284
|
-
end.join(" and ")
|
285
|
-
end
|
286
|
-
|
287
|
-
def self.equal_pair(key, value)
|
288
|
-
if key == :label
|
289
|
-
"@id=//label[normalize-space()=#{xpath_string(value)}]/@for"
|
290
|
-
else
|
291
|
-
"#{lhs_for(key)}=#{xpath_string(value)}"
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
def self.lhs_for(key)
|
296
|
-
case key
|
297
|
-
when :text, 'text'
|
298
|
-
'normalize-space()'
|
299
|
-
when :href
|
300
|
-
'normalize-space(@href)'
|
301
|
-
else
|
302
|
-
"@#{key.to_s.gsub("_", "-")}"
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
def self.xpath_string(value)
|
307
|
-
if value.include? "'"
|
308
|
-
parts = value.split("'", -1).map { |part| "'#{part}'" }
|
309
|
-
string = parts.join(%{,"'",})
|
310
|
-
"concat(#{string})"
|
311
|
-
else
|
312
|
-
"'#{value}'"
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
def self.identifier_for identifier, find_by, find_by_mapping
|
317
|
-
how, what = identifier.keys.first, identifier.values.first
|
318
|
-
return how => what if find_by.include? how or how == :tag_name
|
319
|
-
return find_by_mapping[how] => what if find_by_mapping[how]
|
320
|
-
identifier
|
321
|
-
end
|
322
|
-
|
323
|
-
def self.watir_finders
|
324
|
-
[:class, :id, :index, :name, :xpath]
|
325
|
-
end
|
326
|
-
|
327
|
-
def self.watir_mapping
|
328
|
-
{}
|
329
|
-
end
|
330
|
-
|
331
|
-
def include_platform_for platform
|
332
|
-
platform_information = PageObject::Platforms.get
|
333
|
-
raise ArgumentError,"Expected hash with at least a key :platform for platform information! (#{platform.inspect})" unless platform.class == Hash && platform.has_key?(:platform)
|
334
|
-
platform_name = platform[:platform]
|
335
|
-
|
336
|
-
raise ArgumentError, "Unknown platform #{platform_name}! Expect platform to be one of the following: #{platform_information.keys.inspect}" unless platform_information.keys.include?(platform_name)
|
337
|
-
base_platform_class = "#{platform_information[platform_name]}::"
|
338
|
-
|
339
|
-
@platform = constantize_classname(base_platform_class+ "PageObject").new(@element)
|
340
|
-
end
|
238
|
+
protected
|
341
239
|
|
342
240
|
def to_ary
|
343
241
|
nil
|
@@ -355,10 +253,6 @@ module PageObject
|
|
355
253
|
false
|
356
254
|
end
|
357
255
|
|
358
|
-
def constantize_classname name
|
359
|
-
name.split("::").inject(Object) { |k,n| k.const_get(n) }
|
360
|
-
end
|
361
|
-
|
362
256
|
end
|
363
257
|
end
|
364
258
|
end
|
@@ -6,12 +6,6 @@ module PageObject
|
|
6
6
|
raise "click is not available on the hidden field element"
|
7
7
|
end
|
8
8
|
|
9
|
-
protected
|
10
|
-
|
11
|
-
def self.watir_finders
|
12
|
-
super + [:text, :value]
|
13
|
-
end
|
14
|
-
|
15
9
|
end
|
16
10
|
|
17
11
|
::PageObject::Elements.type_to_class[:hidden] = ::PageObject::Elements::HiddenField
|
@@ -3,16 +3,6 @@ module PageObject
|
|
3
3
|
module Elements
|
4
4
|
class Link < Element
|
5
5
|
|
6
|
-
protected
|
7
|
-
|
8
|
-
def self.watir_finders
|
9
|
-
super + [:href, :text, :css, :title]
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.watir_mapping
|
13
|
-
super.merge({:link => :text, :link_text => :text})
|
14
|
-
end
|
15
|
-
|
16
6
|
end
|
17
7
|
|
18
8
|
::PageObject::Elements.tag_to_class[:a] = ::PageObject::Elements::Link
|