ae_page_objects 1.2.1 → 1.3.0
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 +4 -4
- data/lib/ae_page_objects/concerns/visitable.rb +1 -1
- data/lib/ae_page_objects/core/dsl.rb +18 -18
- data/lib/ae_page_objects/core/site.rb +1 -1
- data/lib/ae_page_objects/document.rb +1 -1
- data/lib/ae_page_objects/document_loader.rb +1 -1
- data/lib/ae_page_objects/element.rb +1 -1
- data/lib/ae_page_objects/element_proxy.rb +53 -17
- data/lib/ae_page_objects/exceptions.rb +14 -2
- data/lib/ae_page_objects/node.rb +2 -2
- data/lib/ae_page_objects/single_window/same_window_loader_strategy.rb +2 -2
- data/lib/ae_page_objects/util/waiter.rb +18 -2
- data/lib/ae_page_objects/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bccdd111c15cbfc24c720ab0ecb2df6615d817af
|
4
|
+
data.tar.gz: 640432edfc7bae3b61ab33c37cb878344a6fdb66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9eccb45c332ac93f9b87c04065d834595d864b5eab6116d8d9cb469fac270a134baf4671c2c2087f7b1df6de22907807d93bad6347cef0e6758d3c293ca72adc
|
7
|
+
data.tar.gz: 9782f24bbc2f0eea7fdf7e9cef46b4bc2554ab15ed7c578aa247b55b8f4d1a0e6333c194e960672cede92e4f46ececea2d590ee97dd6414e80c12daa337c75f8
|
@@ -9,7 +9,7 @@ module AePageObjects
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def ensure_loaded!
|
12
|
-
unless Waiter.
|
12
|
+
unless Waiter.wait_until { self.class.can_load_from_current_url? }
|
13
13
|
raise LoadingPageFailed, "#{self.class.name} cannot be loaded with url '#{current_url_without_params}'"
|
14
14
|
end
|
15
15
|
|
@@ -38,8 +38,8 @@ module AePageObjects
|
|
38
38
|
#
|
39
39
|
# collection :addresses
|
40
40
|
#
|
41
|
-
# Collection class:
|
42
|
-
# Item class:
|
41
|
+
# Collection class: Collection
|
42
|
+
# Item class: Element
|
43
43
|
#
|
44
44
|
# ------------------------------------------------
|
45
45
|
# Signature: (no :is, no :contains, block)
|
@@ -49,18 +49,18 @@ module AePageObjects
|
|
49
49
|
# element :state
|
50
50
|
# end
|
51
51
|
#
|
52
|
-
# Collection class: one-off subclass of
|
53
|
-
# Item class: one-off subclass of
|
52
|
+
# Collection class: one-off subclass of Collection
|
53
|
+
# Item class: one-off subclass of Element
|
54
54
|
# Methods defined on item class:
|
55
|
-
# city() # -> instance of
|
56
|
-
# state() # -> instance of
|
55
|
+
# city() # -> instance of Element
|
56
|
+
# state() # -> instance of Element
|
57
57
|
#
|
58
58
|
# ------------------------------------------------
|
59
59
|
# Signature: (no :is, :contains, no block)
|
60
60
|
#
|
61
61
|
# collection :addresses, :contains => Address
|
62
62
|
#
|
63
|
-
# Collection class: one-off subclass of
|
63
|
+
# Collection class: one-off subclass of Collection
|
64
64
|
# Item class: Address
|
65
65
|
#
|
66
66
|
# ------------------------------------------------
|
@@ -71,11 +71,11 @@ module AePageObjects
|
|
71
71
|
# element :latitude
|
72
72
|
# end
|
73
73
|
#
|
74
|
-
# Collection class: one-off subclass of
|
74
|
+
# Collection class: one-off subclass of Collection element
|
75
75
|
# Item class: one-off subclass of Address
|
76
76
|
# Methods defined on item class:
|
77
|
-
# longitude() # -> instance of
|
78
|
-
# latitude() # -> instance of
|
77
|
+
# longitude() # -> instance of Element
|
78
|
+
# latitude() # -> instance of Element
|
79
79
|
#
|
80
80
|
# ------------------------------------------------
|
81
81
|
# Signature: (:is, no :contains, no block)
|
@@ -96,8 +96,8 @@ module AePageObjects
|
|
96
96
|
# Collection class: one-off subclass of AddressList
|
97
97
|
# Item class: one-off subclass of AddressList.item_class
|
98
98
|
# Methods defined on item class:
|
99
|
-
# longitude() # -> instance of
|
100
|
-
# latitude() # -> instance of
|
99
|
+
# longitude() # -> instance of Element
|
100
|
+
# latitude() # -> instance of Element
|
101
101
|
#
|
102
102
|
# ------------------------------------------------
|
103
103
|
# Signature: (:is, :contains, no block)
|
@@ -118,8 +118,8 @@ module AePageObjects
|
|
118
118
|
# Collection class: one-off subclass of AddressList
|
119
119
|
# Item class: one-off subclass of Address
|
120
120
|
# Methods defined on item class:
|
121
|
-
# longitude() # -> instance of
|
122
|
-
# latitude() # -> instance of
|
121
|
+
# longitude() # -> instance of Element
|
122
|
+
# latitude() # -> instance of Element
|
123
123
|
#
|
124
124
|
def collection(name, options = {}, &block)
|
125
125
|
options ||= {}
|
@@ -136,9 +136,9 @@ module AePageObjects
|
|
136
136
|
|
137
137
|
# create/get the collection class
|
138
138
|
if options[:is]
|
139
|
-
ensure_class_for_param!(:is, options[:is],
|
139
|
+
ensure_class_for_param!(:is, options[:is], Collection)
|
140
140
|
else
|
141
|
-
options[:is] =
|
141
|
+
options[:is] = Collection
|
142
142
|
end
|
143
143
|
|
144
144
|
item_class = options.delete(:contains) || options[:is].item_class
|
@@ -162,7 +162,7 @@ module AePageObjects
|
|
162
162
|
raise ArgumentError, ":is option not supported" if options[:is]
|
163
163
|
raise ArgumentError, "Block required." if block.nil?
|
164
164
|
|
165
|
-
klass = Class.new(
|
165
|
+
klass = Class.new(Form, &block)
|
166
166
|
|
167
167
|
options = options.dup
|
168
168
|
options[:is] = klass
|
@@ -183,7 +183,7 @@ module AePageObjects
|
|
183
183
|
private
|
184
184
|
|
185
185
|
def field_klass(options, &block)
|
186
|
-
klass = options.delete(:is) ||
|
186
|
+
klass = options.delete(:is) || Element
|
187
187
|
|
188
188
|
if block_given?
|
189
189
|
Class.new(klass, &block)
|
@@ -16,44 +16,72 @@ module AePageObjects
|
|
16
16
|
@loaded_element = nil
|
17
17
|
end
|
18
18
|
|
19
|
-
# Provided so that visible? can be asked without
|
20
|
-
# an explicit check for present? first.
|
21
19
|
def visible?
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
wait_until_visible
|
21
|
+
true
|
22
|
+
rescue ElementNotVisible
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def hidden?
|
27
|
+
wait_until_hidden
|
28
|
+
true
|
29
|
+
rescue ElementNotHidden
|
30
|
+
false
|
26
31
|
end
|
27
32
|
|
28
33
|
def not_visible?
|
29
|
-
|
30
|
-
inst = presence
|
31
|
-
inst.nil? || ! inst.visible?
|
32
|
-
end
|
34
|
+
hidden?
|
33
35
|
end
|
34
36
|
|
35
37
|
def present?
|
36
|
-
|
38
|
+
wait_until_present
|
37
39
|
true
|
38
40
|
rescue ElementNotPresent
|
39
41
|
false
|
40
42
|
end
|
41
43
|
|
42
|
-
def
|
43
|
-
|
44
|
+
def absent?
|
45
|
+
wait_until_absent
|
44
46
|
true
|
45
47
|
rescue ElementNotAbsent
|
46
48
|
false
|
47
49
|
end
|
48
50
|
|
51
|
+
def not_present?
|
52
|
+
absent?
|
53
|
+
end
|
54
|
+
|
49
55
|
def presence
|
50
56
|
implicit_element
|
51
57
|
rescue LoadingElementFailed
|
52
58
|
nil
|
53
59
|
end
|
54
60
|
|
55
|
-
def
|
56
|
-
|
61
|
+
def wait_until_visible(timeout = nil)
|
62
|
+
is_visible = Waiter.wait_until(timeout) do
|
63
|
+
inst = presence
|
64
|
+
! inst.nil? && inst.visible?
|
65
|
+
end
|
66
|
+
|
67
|
+
unless is_visible
|
68
|
+
raise ElementNotVisible, "element_class: #{@element_class}, options: #{@options.inspect}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def wait_until_hidden(timeout = nil)
|
73
|
+
is_hidden = Waiter.wait_until(timeout) do
|
74
|
+
inst = presence
|
75
|
+
inst.nil? || ! inst.visible?
|
76
|
+
end
|
77
|
+
|
78
|
+
unless is_hidden
|
79
|
+
raise ElementNotHidden, "element_class: #{@element_class}, options: #{@options.inspect}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def wait_until_present(timeout = nil)
|
84
|
+
is_present = Waiter.wait_until(timeout) do
|
57
85
|
! presence.nil?
|
58
86
|
end
|
59
87
|
|
@@ -62,8 +90,12 @@ module AePageObjects
|
|
62
90
|
end
|
63
91
|
end
|
64
92
|
|
65
|
-
def
|
66
|
-
|
93
|
+
def wait_for_presence(timeout = nil)
|
94
|
+
wait_until_present(timeout)
|
95
|
+
end
|
96
|
+
|
97
|
+
def wait_until_absent(timeout = nil)
|
98
|
+
is_absent = Waiter.wait_until(timeout) do
|
67
99
|
check_absence
|
68
100
|
end
|
69
101
|
|
@@ -72,6 +104,10 @@ module AePageObjects
|
|
72
104
|
end
|
73
105
|
end
|
74
106
|
|
107
|
+
def wait_for_absence(timeout = nil)
|
108
|
+
wait_until_absent(timeout)
|
109
|
+
end
|
110
|
+
|
75
111
|
def is_a?(type)
|
76
112
|
type == @element_class || type == ElementProxy
|
77
113
|
end
|
@@ -13,10 +13,19 @@ module AePageObjects
|
|
13
13
|
class LoadingElementFailed < LoadingFailed
|
14
14
|
end
|
15
15
|
|
16
|
-
class
|
16
|
+
class ElementExpectationError < Error
|
17
17
|
end
|
18
18
|
|
19
|
-
class
|
19
|
+
class ElementNotVisible < ElementExpectationError
|
20
|
+
end
|
21
|
+
|
22
|
+
class ElementNotHidden < ElementExpectationError
|
23
|
+
end
|
24
|
+
|
25
|
+
class ElementNotPresent < ElementExpectationError
|
26
|
+
end
|
27
|
+
|
28
|
+
class ElementNotAbsent < ElementExpectationError
|
20
29
|
end
|
21
30
|
|
22
31
|
class PathNotResolvable < Error
|
@@ -30,4 +39,7 @@ module AePageObjects
|
|
30
39
|
|
31
40
|
class WindowNotFound < Error
|
32
41
|
end
|
42
|
+
|
43
|
+
class WaitTimeoutError < Error
|
44
|
+
end
|
33
45
|
end
|
data/lib/ae_page_objects/node.rb
CHANGED
@@ -26,8 +26,8 @@ module AePageObjects
|
|
26
26
|
class_eval <<-RUBY
|
27
27
|
def #{m}(*args, &block)
|
28
28
|
node.send(:#{m}, *args, &block)
|
29
|
-
rescue Capybara::ElementNotFound
|
30
|
-
raise
|
29
|
+
rescue Capybara::ElementNotFound => e
|
30
|
+
raise LoadingElementFailed, e.message
|
31
31
|
end
|
32
32
|
RUBY
|
33
33
|
end
|
@@ -19,13 +19,13 @@ module AePageObjects
|
|
19
19
|
|
20
20
|
def load_document(document_class)
|
21
21
|
document_class.new
|
22
|
-
rescue
|
22
|
+
rescue LoadingPageFailed
|
23
23
|
nil
|
24
24
|
end
|
25
25
|
|
26
26
|
def condition_matches?(document, condition)
|
27
27
|
condition.match?(document)
|
28
|
-
rescue
|
28
|
+
rescue ElementExpectationError, LoadingElementFailed
|
29
29
|
false
|
30
30
|
end
|
31
31
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module AePageObjects
|
2
2
|
module Waiter
|
3
|
-
def self.
|
4
|
-
seconds_to_wait =
|
3
|
+
def self.wait_until(timeout = nil, &block)
|
4
|
+
seconds_to_wait = timeout || Capybara.default_wait_time
|
5
5
|
start_time = Time.now
|
6
6
|
|
7
7
|
until result = Capybara.using_wait_time(0, &block)
|
@@ -16,5 +16,21 @@ module AePageObjects
|
|
16
16
|
|
17
17
|
result
|
18
18
|
end
|
19
|
+
|
20
|
+
def self.wait_for(*args, &block)
|
21
|
+
wait_until(*args, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.wait_until!(timeout = nil)
|
25
|
+
result = wait_until(timeout) do
|
26
|
+
yield
|
27
|
+
end
|
28
|
+
|
29
|
+
unless result
|
30
|
+
raise WaitTimeoutError, "Timed out waiting for condition"
|
31
|
+
end
|
32
|
+
|
33
|
+
result
|
34
|
+
end
|
19
35
|
end
|
20
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_page_objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Donnie Tognazzini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|