ae_page_objects 5.0.0.tim1 → 6.0.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/ae_page_objects.gemspec +23 -0
- data/lib/ae_page_objects/element.rb +19 -12
- data/lib/ae_page_objects/element_proxy.rb +24 -27
- data/lib/ae_page_objects/elements/collection.rb +3 -7
- data/lib/ae_page_objects/node.rb +2 -4
- data/lib/ae_page_objects/rails/application_router.rb +9 -34
- data/lib/ae_page_objects/version.rb +1 -1
- metadata +25 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d03326a2bcedb51c1d268690baee1c9adea3c44cada101beaa4f414c22a74946
|
4
|
+
data.tar.gz: 80e7c8b74ee935f28e1b80c7c698659d6d9f58b9886d087f10f8e3f2ee191820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f4f9b6b8042099edbba969631a2c09ac94466cb62ec898d8249c81eac70052a100ca79d400b0aef4fb6e32f40bf06cf93e4fafee641f6241be4d2e66d69de3b
|
7
|
+
data.tar.gz: b787fa1e7d7ed7bcc76ddfe44061092b9807a3454188e7d0d4e16550231decfc670f022c4b24cdd186fad7c22c4179e39b3cb310a87793acc3a1c3a5c2b6fb06
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative 'lib/ae_page_objects/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ae_page_objects'
|
8
|
+
spec.version = AePageObjects::VERSION
|
9
|
+
spec.platform = Gem::Platform::RUBY
|
10
|
+
spec.author = 'AppFolio'
|
11
|
+
spec.email = 'opensource@appfolio.com'
|
12
|
+
spec.description = 'Capybara Page Objects pattern.'
|
13
|
+
spec.summary = spec.description
|
14
|
+
spec.homepage = 'https://github.com/appfolio/ae_page_objects'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.files = Dir['**/*'].select { |f| f[%r{^(lib/|LICENSE.txt|.*gemspec)}] }
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3')
|
19
|
+
|
20
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
+
|
22
|
+
spec.add_dependency('capybara', ['>= 3', '< 4'])
|
23
|
+
end
|
@@ -89,6 +89,11 @@ module AePageObjects
|
|
89
89
|
def configure(options)
|
90
90
|
@locator = options.delete(:locator)
|
91
91
|
@name = options.delete(:name)
|
92
|
+
if options.key?(:wait)
|
93
|
+
@wait = options.delete(:wait)
|
94
|
+
else
|
95
|
+
@wait = true
|
96
|
+
end
|
92
97
|
|
93
98
|
@name = @name.to_s if @name
|
94
99
|
end
|
@@ -107,20 +112,22 @@ module AePageObjects
|
|
107
112
|
|
108
113
|
def scoped_node
|
109
114
|
locator = eval_locator(@locator)
|
110
|
-
if locator.empty?
|
111
|
-
parent.node
|
112
|
-
else
|
113
|
-
default_options = { minimum: 0 }
|
114
|
-
if locator.last.is_a?(::Hash)
|
115
|
-
locator[-1] = default_options.merge(locator.last)
|
116
|
-
else
|
117
|
-
locator.push(default_options)
|
118
|
-
end
|
119
115
|
|
120
|
-
|
121
|
-
|
122
|
-
|
116
|
+
return parent.node if locator.empty?
|
117
|
+
|
118
|
+
default_options = { minimum: 0 }
|
119
|
+
if locator.last.is_a?(::Hash)
|
120
|
+
default_options.merge!(locator.pop)
|
121
|
+
end
|
122
|
+
|
123
|
+
if @wait
|
124
|
+
node = AePageObjects.wait_until { parent.node.first(*locator, **default_options) }
|
125
|
+
else
|
126
|
+
node = parent.node.first(*locator, **default_options)
|
127
|
+
raise LoadingElementFailed, 'Element Not Found' unless node
|
123
128
|
end
|
129
|
+
node.allow_reload!
|
130
|
+
node
|
124
131
|
rescue AePageObjects::WaitTimeoutError => e
|
125
132
|
raise LoadingElementFailed, e.message
|
126
133
|
end
|
@@ -15,36 +15,22 @@ module AePageObjects
|
|
15
15
|
@loaded_element = nil
|
16
16
|
end
|
17
17
|
|
18
|
-
def visible?
|
19
|
-
|
20
|
-
|
21
|
-
true
|
22
|
-
rescue ElementNotVisible
|
23
|
-
false
|
18
|
+
def visible?
|
19
|
+
reload_element
|
20
|
+
@loaded_element&.visible?
|
24
21
|
end
|
25
22
|
|
26
|
-
def hidden?
|
27
|
-
|
28
|
-
wait_until_hidden(options[:wait])
|
29
|
-
true
|
30
|
-
rescue ElementNotHidden
|
31
|
-
false
|
23
|
+
def hidden?
|
24
|
+
!visible?
|
32
25
|
end
|
33
26
|
|
34
|
-
def present?
|
35
|
-
|
36
|
-
|
37
|
-
true
|
38
|
-
rescue ElementNotPresent
|
39
|
-
false
|
27
|
+
def present?
|
28
|
+
reload_element
|
29
|
+
!@loaded_element.nil?
|
40
30
|
end
|
41
31
|
|
42
|
-
def absent?
|
43
|
-
|
44
|
-
wait_until_absent(options[:wait])
|
45
|
-
true
|
46
|
-
rescue ElementNotAbsent
|
47
|
-
false
|
32
|
+
def absent?
|
33
|
+
!present?
|
48
34
|
end
|
49
35
|
|
50
36
|
def presence
|
@@ -127,8 +113,19 @@ module AePageObjects
|
|
127
113
|
|
128
114
|
private
|
129
115
|
|
130
|
-
def load_element
|
131
|
-
@
|
116
|
+
def load_element(wait: true)
|
117
|
+
args = @args.dup
|
118
|
+
|
119
|
+
options_or_locator = args.pop
|
120
|
+
options = if options_or_locator.is_a?(Hash)
|
121
|
+
options_or_locator.merge(wait: wait)
|
122
|
+
else
|
123
|
+
{ locator: options_or_locator, wait: wait }
|
124
|
+
end
|
125
|
+
|
126
|
+
args << options
|
127
|
+
|
128
|
+
@element_class.new(*args)
|
132
129
|
end
|
133
130
|
|
134
131
|
def implicit_element
|
@@ -136,7 +133,7 @@ module AePageObjects
|
|
136
133
|
end
|
137
134
|
|
138
135
|
def reload_element
|
139
|
-
@loaded_element = load_element
|
136
|
+
@loaded_element = load_element(wait: false)
|
140
137
|
rescue LoadingElementFailed
|
141
138
|
@loaded_element = nil
|
142
139
|
end
|
@@ -52,7 +52,7 @@ module AePageObjects
|
|
52
52
|
# wait time set to 0.
|
53
53
|
#
|
54
54
|
Capybara.using_wait_time(0) do
|
55
|
-
node.all(:xpath, item_xpath, options).size
|
55
|
+
node.all(:xpath, item_xpath, **options).size
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -90,7 +90,6 @@ module AePageObjects
|
|
90
90
|
}
|
91
91
|
|
92
92
|
if query_args[1].is_a?(XPath::Expression)
|
93
|
-
#
|
94
93
|
# Use the { exact: true } setting for XPath selectors that use "XPath.is". For example, given the XPath
|
95
94
|
# XPath.descendant(:div)[XPath.text.is('Example Text')]
|
96
95
|
# the resulting path will be
|
@@ -98,17 +97,14 @@ module AePageObjects
|
|
98
97
|
# instead of
|
99
98
|
# .//div[contains(./text(), 'Example Text')]
|
100
99
|
# See https://github.com/jnicklas/capybara#exactness for more information.
|
101
|
-
#
|
102
100
|
default_options[:exact] = true
|
103
101
|
end
|
104
102
|
|
105
103
|
if query_args.last.is_a?(::Hash)
|
106
|
-
|
107
|
-
else
|
108
|
-
query_args.push(default_options)
|
104
|
+
default_options.merge!(query_args.pop)
|
109
105
|
end
|
110
106
|
|
111
|
-
query = Capybara::Queries::SelectorQuery.new(*query_args)
|
107
|
+
query = Capybara::Queries::SelectorQuery.new(*query_args, **default_options)
|
112
108
|
|
113
109
|
result = query.xpath
|
114
110
|
|
data/lib/ae_page_objects/node.rb
CHANGED
@@ -22,12 +22,10 @@ module AePageObjects
|
|
22
22
|
else
|
23
23
|
default_options = { wait: false }
|
24
24
|
if locator.last.is_a?(::Hash)
|
25
|
-
|
26
|
-
else
|
27
|
-
locator.push(default_options)
|
25
|
+
default_options.merge!(locator.pop)
|
28
26
|
end
|
29
27
|
|
30
|
-
node.all(*locator).any?
|
28
|
+
node.all(*locator, **default_options).any?
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
@@ -4,9 +4,7 @@ module AePageObjects
|
|
4
4
|
class ApplicationRouter < BasicRouter
|
5
5
|
|
6
6
|
# This whole file is a kludge and probably belongs in an ae_page_objects-rails extension
|
7
|
-
|
8
7
|
module Recognizer
|
9
|
-
|
10
8
|
class Base
|
11
9
|
def generate_path(named_route, *args)
|
12
10
|
if routes.respond_to?("#{named_route}_path")
|
@@ -32,7 +30,7 @@ module AePageObjects
|
|
32
30
|
false
|
33
31
|
end
|
34
32
|
|
35
|
-
|
33
|
+
private
|
36
34
|
|
37
35
|
def routes
|
38
36
|
raise NotImplementedError, "You must implement routes"
|
@@ -60,9 +58,8 @@ module AePageObjects
|
|
60
58
|
ResolvedRoute = Struct.new(:controller, :action)
|
61
59
|
end
|
62
60
|
|
63
|
-
class
|
64
|
-
|
65
|
-
private
|
61
|
+
class Rails6Plus < Base
|
62
|
+
private
|
66
63
|
|
67
64
|
def request_for(url, method)
|
68
65
|
::Rails.application.routes.request_class.new(env_for(url, method))
|
@@ -77,7 +74,8 @@ module AePageObjects
|
|
77
74
|
end
|
78
75
|
|
79
76
|
def normalize_url(url)
|
80
|
-
|
77
|
+
require 'action_dispatch/journey'
|
78
|
+
ActionDispatch::Journey::Router::Utils.normalize_path(url) unless url =~ %r{://}
|
81
79
|
end
|
82
80
|
|
83
81
|
def router
|
@@ -93,25 +91,6 @@ module AePageObjects
|
|
93
91
|
end
|
94
92
|
end
|
95
93
|
end
|
96
|
-
|
97
|
-
class Rails32 < Rails3
|
98
|
-
|
99
|
-
private
|
100
|
-
|
101
|
-
def normalize_url(url)
|
102
|
-
Journey::Router::Utils.normalize_path(url) unless url =~ %r{://}
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class Rails4Plus < Rails32
|
107
|
-
|
108
|
-
private
|
109
|
-
|
110
|
-
def normalize_url(url)
|
111
|
-
require 'action_dispatch/journey'
|
112
|
-
ActionDispatch::Journey::Router::Utils.normalize_path(url) unless url =~ %r{://}
|
113
|
-
end
|
114
|
-
end
|
115
94
|
end
|
116
95
|
|
117
96
|
def path_recognizes_url?(path, url)
|
@@ -133,16 +112,12 @@ module AePageObjects
|
|
133
112
|
private
|
134
113
|
|
135
114
|
def recognizer
|
136
|
-
@recognizer ||= case ::Rails.
|
137
|
-
when
|
138
|
-
Recognizer::
|
139
|
-
when /\A3\.2/
|
140
|
-
Recognizer::Rails32.new
|
141
|
-
when /\A(4\.[012]|5\.0)/
|
142
|
-
Recognizer::Rails4Plus.new
|
115
|
+
@recognizer ||= case ::Rails.gem_version
|
116
|
+
when Gem::Requirement.new('>= 6.0', '< 8.0')
|
117
|
+
Recognizer::Rails6Plus.new
|
143
118
|
else
|
144
119
|
warn "[WARNING]: AePageObjects is not tested against Rails #{::Rails.version} and may behave in an undefined manner."
|
145
|
-
Recognizer::
|
120
|
+
Recognizer::Rails6Plus.new
|
146
121
|
end
|
147
122
|
end
|
148
123
|
end
|
metadata
CHANGED
@@ -1,36 +1,42 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_page_objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- AppFolio
|
8
|
-
autorequire:
|
7
|
+
- AppFolio
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3
|
19
|
+
version: '3'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '4'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3'
|
30
|
+
- - "<"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
description: Capybara Page Objects pattern
|
28
|
-
email:
|
29
|
-
- engineering@appfolio.com
|
32
|
+
version: '4'
|
33
|
+
description: Capybara Page Objects pattern.
|
34
|
+
email: opensource@appfolio.com
|
30
35
|
executables: []
|
31
36
|
extensions: []
|
32
37
|
extra_rdoc_files: []
|
33
38
|
files:
|
39
|
+
- ae_page_objects.gemspec
|
34
40
|
- lib/ae_page_objects.rb
|
35
41
|
- lib/ae_page_objects/core/basic_router.rb
|
36
42
|
- lib/ae_page_objects/core/dsl.rb
|
@@ -60,11 +66,12 @@ files:
|
|
60
66
|
- lib/ae_page_objects/util/internal_helpers.rb
|
61
67
|
- lib/ae_page_objects/util/wait_time_manager.rb
|
62
68
|
- lib/ae_page_objects/version.rb
|
63
|
-
homepage:
|
69
|
+
homepage: https://github.com/appfolio/ae_page_objects
|
64
70
|
licenses:
|
65
71
|
- MIT
|
66
|
-
metadata:
|
67
|
-
|
72
|
+
metadata:
|
73
|
+
allowed_push_host: https://rubygems.org
|
74
|
+
post_install_message:
|
68
75
|
rdoc_options: []
|
69
76
|
require_paths:
|
70
77
|
- lib
|
@@ -72,16 +79,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
79
|
requirements:
|
73
80
|
- - ">="
|
74
81
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
82
|
+
version: '3'
|
76
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
84
|
requirements:
|
78
85
|
- - ">"
|
79
86
|
- !ruby/object:Gem::Version
|
80
87
|
version: 1.3.1
|
81
88
|
requirements: []
|
82
|
-
|
83
|
-
|
84
|
-
signing_key:
|
89
|
+
rubygems_version: 3.4.6
|
90
|
+
signing_key:
|
85
91
|
specification_version: 4
|
86
|
-
summary: Capybara Page Objects pattern
|
92
|
+
summary: Capybara Page Objects pattern.
|
87
93
|
test_files: []
|