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
@@ -34,6 +34,7 @@ module PageObject
|
|
34
34
|
populate_checkbox(key, value) if is_checkbox?(key) and is_enabled?(key)
|
35
35
|
populate_radiobuttongroup(key, value) if is_radiobuttongroup?(key)
|
36
36
|
populate_radiobutton(key, value) if is_radiobutton?(key) and is_enabled?(key)
|
37
|
+
populate_select_list(key, value) if is_select_list?(key)
|
37
38
|
populate_text(key, value) if is_text?(key) and is_enabled?(key)
|
38
39
|
end
|
39
40
|
end
|
@@ -57,7 +58,17 @@ module PageObject
|
|
57
58
|
return self.send("select_#{key}", value)
|
58
59
|
end
|
59
60
|
|
61
|
+
def populate_select_list(key, value)
|
62
|
+
select_element = self.send("#{key}_element")
|
63
|
+
if select_element.options.include?(value)
|
64
|
+
select_element.select(value)
|
65
|
+
else
|
66
|
+
select_element.select_value(value)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
60
70
|
def is_text?(key)
|
71
|
+
return false if is_select_list?(key)
|
61
72
|
respond_to?("#{key}=".to_sym)
|
62
73
|
end
|
63
74
|
|
@@ -73,6 +84,10 @@ module PageObject
|
|
73
84
|
respond_to?("select_#{key}".to_sym) and respond_to?("#{key}_values")
|
74
85
|
end
|
75
86
|
|
87
|
+
def is_select_list?(key)
|
88
|
+
respond_to?("#{key}_options".to_sym)
|
89
|
+
end
|
90
|
+
|
76
91
|
def is_enabled?(key)
|
77
92
|
return false if is_radiobuttongroup?(key)
|
78
93
|
return true if (self.send "#{key}_element").tag_name == "textarea"
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module PageObject
|
2
2
|
module Platforms
|
3
|
-
module
|
3
|
+
module Watir
|
4
4
|
|
5
5
|
def self.create_page_object(browser)
|
6
6
|
browser = selenium_browser(browser) unless watir?(browser)
|
7
|
-
return
|
7
|
+
return Watir::PageObject.new(browser)
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.is_for?(browser)
|
@@ -19,7 +19,7 @@ module PageObject
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.root_element_for root
|
22
|
-
Elements::Element.new
|
22
|
+
Elements::Element.new(root) if is_for?(root)
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.browser_root_for browser
|
@@ -48,5 +48,3 @@ module PageObject
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
|
-
|
52
|
-
PageObject::Platforms.register(:watir, PageObject::Platforms::WatirWebDriver)
|
@@ -4,7 +4,7 @@ require 'page-object/core_ext/string'
|
|
4
4
|
|
5
5
|
module PageObject
|
6
6
|
module Platforms
|
7
|
-
module
|
7
|
+
module Watir
|
8
8
|
|
9
9
|
#
|
10
10
|
# Watir implementation of the page object platform driver. You should not use the
|
@@ -14,8 +14,6 @@ module PageObject
|
|
14
14
|
class PageObject
|
15
15
|
attr_reader :browser
|
16
16
|
|
17
|
-
PLATFORM_NAME = :watir
|
18
|
-
|
19
17
|
def self.define_widget_accessors(widget_tag, widget_class, base_element_tag)
|
20
18
|
define_widget_singular_accessor(base_element_tag, widget_class, widget_tag)
|
21
19
|
define_widget_multiple_accessor(base_element_tag, widget_class, widget_tag)
|
@@ -139,8 +137,7 @@ module PageObject
|
|
139
137
|
element = browser.execute_script("return document.activeElement")
|
140
138
|
type = element.type.to_sym if element.tag_name.to_sym == :input
|
141
139
|
cls = ::PageObject::Elements.element_class_for(element.tag_name, type)
|
142
|
-
|
143
|
-
cls.new(element, :platform => self.class::PLATFORM_NAME)
|
140
|
+
cls.new(element)
|
144
141
|
end
|
145
142
|
|
146
143
|
#
|
@@ -295,8 +292,10 @@ module PageObject
|
|
295
292
|
# See PageObject::Accessors#select_list
|
296
293
|
#
|
297
294
|
def select_list_value_for(identifier)
|
298
|
-
|
295
|
+
options = find_watir_elements("select_list(identifier).selected_options",
|
299
296
|
Elements::SelectList, identifier)
|
297
|
+
return nil if options.empty?
|
298
|
+
options.first.text
|
300
299
|
end
|
301
300
|
|
302
301
|
#
|
@@ -1039,14 +1038,14 @@ module PageObject
|
|
1039
1038
|
identifier, frame_identifiers = parse_identifiers(identifier, type, tag_name)
|
1040
1039
|
elements = @browser.instance_eval "#{nested_frames(frame_identifiers)}#{the_call}"
|
1041
1040
|
switch_to_default_content(frame_identifiers)
|
1042
|
-
elements.map { |element| type.new(element
|
1041
|
+
elements.map { |element| type.new(element) }
|
1043
1042
|
end
|
1044
1043
|
|
1045
1044
|
def find_watir_element(the_call, type, identifier, tag_name=nil)
|
1046
1045
|
identifier, frame_identifiers = parse_identifiers(identifier, type, tag_name)
|
1047
1046
|
element = @browser.instance_eval "#{nested_frames(frame_identifiers)}#{the_call}"
|
1048
1047
|
switch_to_default_content(frame_identifiers)
|
1049
|
-
type.new(element
|
1048
|
+
type.new(element)
|
1050
1049
|
end
|
1051
1050
|
|
1052
1051
|
def find_watir_pages(identifier, page_class)
|
@@ -1071,18 +1070,11 @@ module PageObject
|
|
1071
1070
|
end
|
1072
1071
|
|
1073
1072
|
def parse_identifiers(identifier, element, tag_name=nil)
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
return identifier, frame_identifiers
|
1078
|
-
end
|
1079
|
-
|
1080
|
-
def add_tagname_if_needed identifier, tag
|
1081
|
-
return identifier if identifier.length < 2 and not identifier[:name]
|
1082
|
-
identifier[:tag_name] = tag if identifier[:name]
|
1083
|
-
identifier
|
1073
|
+
new_identifiers = identifier.dup
|
1074
|
+
frame_identifiers = new_identifiers.delete(:frame)
|
1075
|
+
return new_identifiers, frame_identifiers
|
1084
1076
|
end
|
1085
|
-
|
1077
|
+
|
1086
1078
|
def nested_frames(frame_identifiers)
|
1087
1079
|
return if frame_identifiers.nil?
|
1088
1080
|
frame_str = ''
|
@@ -1103,7 +1095,7 @@ module PageObject
|
|
1103
1095
|
end
|
1104
1096
|
|
1105
1097
|
def switch_to_default_content(frame_identifiers)
|
1106
|
-
@browser.wd.switch_to.default_content unless frame_identifiers.nil?
|
1098
|
+
@browser.browser.wd.switch_to.default_content unless frame_identifiers.nil?
|
1107
1099
|
end
|
1108
1100
|
|
1109
1101
|
def switch_to_frame(frame_identifiers)
|
data/lib/page-object/version.rb
CHANGED
data/lib/page-object/widgets.rb
CHANGED
@@ -20,24 +20,12 @@ module PageObject
|
|
20
20
|
define_nested_elements(Elements::Element, widget_tag)
|
21
21
|
define_locators(PageObject, widget_tag)
|
22
22
|
|
23
|
-
PageObject::Platforms.
|
24
|
-
platform_class = constantize_classname("PageObject::Platforms::#{platform}::PageObject")
|
25
|
-
if platform_class.respond_to?(:define_widget_accessors)
|
26
|
-
platform_class.send(:define_widget_accessors,widget_tag, widget_class, base_element_tag)
|
27
|
-
else
|
28
|
-
$stderr.puts "*** WARNING"
|
29
|
-
$stderr.puts "*** Platform PageObject::Platforms::#{platform} does not support widgets! Please add the 'define_widget_accessors' method in PageObject::Platforms::#{platform}::PageObject to support widgets."
|
30
|
-
end
|
31
|
-
}
|
23
|
+
PageObject::Platforms::Watir::PageObject.define_widget_accessors(widget_tag, widget_class, base_element_tag)
|
32
24
|
end
|
33
25
|
end
|
34
26
|
|
35
27
|
private
|
36
28
|
|
37
|
-
def self.constantize_classname name
|
38
|
-
name.split("::").inject(Object) { |k,n| k.const_get(n) }
|
39
|
-
end
|
40
|
-
|
41
29
|
def self.define_accessors(base, widget_tag, widget_class)
|
42
30
|
accessors_module = Module.new do
|
43
31
|
define_method widget_tag do |name, *identifier_args, &block|
|
data/page-object.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.name = "page-object"
|
8
8
|
s.version = PageObject::VERSION
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
|
-
s.authors = ["Jeff Morgan", '
|
11
|
-
s.email = ["jeff.morgan@leandog.com", '
|
10
|
+
s.authors = ["Jeff Morgan", 'Alexis Andersen']
|
11
|
+
s.email = ["jeff.morgan@leandog.com", 'alexis.t.andersen@gmail.com']
|
12
12
|
s.license = 'MIT'
|
13
13
|
s.homepage = "http://github.com/cheezy/page-object"
|
14
14
|
s.summary = %q{Page Object DSL for browser testing}
|
@@ -19,13 +19,13 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_dependency 'watir', '~> 6.0'
|
21
21
|
s.add_dependency 'selenium-webdriver', '~> 3.0'
|
22
|
-
s.add_dependency 'page_navigation', '>= 0.
|
23
|
-
s.add_dependency 'net-http-persistent', '~> 3.0'
|
22
|
+
s.add_dependency 'page_navigation', '>= 0.10'
|
24
23
|
|
25
|
-
s.add_development_dependency 'rspec', '
|
26
|
-
s.add_development_dependency 'cucumber', '
|
24
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
25
|
+
s.add_development_dependency 'cucumber', '~> 2.0'
|
27
26
|
s.add_development_dependency 'yard', '>= 0.7.2'
|
28
27
|
s.add_development_dependency 'rack', '~> 1.0'
|
29
28
|
s.add_development_dependency 'coveralls', '~> 0.8.1'
|
29
|
+
s.add_development_dependency 'net-http-persistent'
|
30
30
|
|
31
31
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: '2.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Morgan
|
8
|
-
-
|
8
|
+
- Alexis Andersen
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir
|
@@ -45,56 +45,42 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0.
|
48
|
+
version: '0.10'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0.
|
55
|
+
version: '0.10'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '3.0'
|
63
|
-
type: :
|
63
|
+
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '3.0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: rspec
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - ">="
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: 3.0.0
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 3.0.0
|
84
70
|
- !ruby/object:Gem::Dependency
|
85
71
|
name: cucumber
|
86
72
|
requirement: !ruby/object:Gem::Requirement
|
87
73
|
requirements:
|
88
|
-
- - "
|
74
|
+
- - "~>"
|
89
75
|
- !ruby/object:Gem::Version
|
90
|
-
version: 2.0
|
76
|
+
version: '2.0'
|
91
77
|
type: :development
|
92
78
|
prerelease: false
|
93
79
|
version_requirements: !ruby/object:Gem::Requirement
|
94
80
|
requirements:
|
95
|
-
- - "
|
81
|
+
- - "~>"
|
96
82
|
- !ruby/object:Gem::Version
|
97
|
-
version: 2.0
|
83
|
+
version: '2.0'
|
98
84
|
- !ruby/object:Gem::Dependency
|
99
85
|
name: yard
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,10 +123,24 @@ dependencies:
|
|
137
123
|
- - "~>"
|
138
124
|
- !ruby/object:Gem::Version
|
139
125
|
version: 0.8.1
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: net-http-persistent
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
140
|
description: Page Object DSL that works with both Watir and Selenium
|
141
141
|
email:
|
142
142
|
- jeff.morgan@leandog.com
|
143
|
-
-
|
143
|
+
- alexis.t.andersen@gmail.com
|
144
144
|
executables: []
|
145
145
|
extensions: []
|
146
146
|
extra_rdoc_files: []
|
@@ -200,12 +200,10 @@ files:
|
|
200
200
|
- lib/page-object/javascript/prototype.rb
|
201
201
|
- lib/page-object/javascript/yui.rb
|
202
202
|
- lib/page-object/javascript_framework_facade.rb
|
203
|
-
- lib/page-object/loads_platform.rb
|
204
203
|
- lib/page-object/locator_generator.rb
|
205
204
|
- lib/page-object/nested_elements.rb
|
206
205
|
- lib/page-object/page_factory.rb
|
207
206
|
- lib/page-object/page_populator.rb
|
208
|
-
- lib/page-object/platforms.rb
|
209
207
|
- lib/page-object/platforms/watir.rb
|
210
208
|
- lib/page-object/platforms/watir/page_object.rb
|
211
209
|
- lib/page-object/section_collection.rb
|
@@ -233,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
231
|
version: '0'
|
234
232
|
requirements: []
|
235
233
|
rubyforge_project:
|
236
|
-
rubygems_version: 2.5.
|
234
|
+
rubygems_version: 2.5.2
|
237
235
|
signing_key:
|
238
236
|
specification_version: 4
|
239
237
|
summary: Page Object DSL for browser testing
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module PageObject
|
2
|
-
#
|
3
|
-
# module which provides a function for determining
|
4
|
-
# which platform to provide to the page object
|
5
|
-
#
|
6
|
-
module LoadsPlatform
|
7
|
-
#
|
8
|
-
# Determines which platform the Page Object should use based upon browser
|
9
|
-
#
|
10
|
-
# @example
|
11
|
-
# platform = load_platform(watir_browser, PageObject.Adapters.list).send(:new, watir_browser)
|
12
|
-
#
|
13
|
-
# @param [Object] A browser driver that has a supported adapter
|
14
|
-
# @param [adapters] a list of adapters that are currently supported
|
15
|
-
# @returns [PageObject]
|
16
|
-
#
|
17
|
-
def load_platform(browser, adapters)
|
18
|
-
adapter_for(browser,adapters).create_page_object(browser)
|
19
|
-
end
|
20
|
-
|
21
|
-
def browser_for root,adapters
|
22
|
-
adapter_for(root,adapters).browser_for(root)
|
23
|
-
end
|
24
|
-
|
25
|
-
def adapter_for element_or_browser, adapters
|
26
|
-
adapter = adapters.values.find { |adapter|
|
27
|
-
adapter.is_for?(element_or_browser)
|
28
|
-
}
|
29
|
-
unless adapter
|
30
|
-
message = "Unable to pick a platform for the provided browser or element: #{element_or_browser.inspect}."
|
31
|
-
message += "\nnil was passed to the PageObject constructor instead of a valid browser or element object." if element_or_browser.nil?
|
32
|
-
raise message
|
33
|
-
end
|
34
|
-
adapter
|
35
|
-
end
|
36
|
-
|
37
|
-
def root_element_for root, adapters
|
38
|
-
adapter_for(root,adapters).root_element_for(root)
|
39
|
-
end
|
40
|
-
|
41
|
-
def browser_root_for browser, adapters
|
42
|
-
adapter_for(browser,adapters).browser_root_for(browser)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'page-object/loads_platform'
|
2
|
-
|
3
|
-
module PageObject
|
4
|
-
module Platforms
|
5
|
-
@@adapters = {}
|
6
|
-
|
7
|
-
def self.get
|
8
|
-
@@adapters
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.register(key, adapter)
|
12
|
-
@@adapters[key] = adapter
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
require 'page-object/platforms/watir'
|
17
|
-
|