ae_page_objects 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1496697b39e5a7662d536eda0f8ca5fef935b6b7
4
- data.tar.gz: 18b7a97561c00230d65f3e5a9c2ab540e5c9dc6d
3
+ metadata.gz: bccdd111c15cbfc24c720ab0ecb2df6615d817af
4
+ data.tar.gz: 640432edfc7bae3b61ab33c37cb878344a6fdb66
5
5
  SHA512:
6
- metadata.gz: 6ec2500cc1c2ded7fa193dabd15f3e3813a427b459508d1732ba182f29ec39fb8e4b530abd96ea89d94875c156ab67c68fb53431fcbe34fbbeb2e2fef780c831
7
- data.tar.gz: cb79d33d0817bfede524f924a1ccb660cf22b6f124d9dc96bccb2755d445a96311f4aa7e1792293e44c7d066d3e76a591f10a8ff62c39e4045ba213021b07309
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.wait_for { self.class.can_load_from_current_url? }
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: ::AePageObjects::Collection
42
- # Item class: ::AePageObjects::Element
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 ::AePageObjects::Collection
53
- # Item class: one-off subclass of ::AePageObjects::Element
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 ::AePageObjects::Element
56
- # state() # -> instance of ::AePageObjects::Element
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 ::AePageObjects::Collection
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 ::AePageObjects::Collection element
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 ::AePageObjects::Element
78
- # latitude() # -> instance of ::AePageObjects::Element
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 ::AePageObjects::Element
100
- # latitude() # -> instance of ::AePageObjects::Element
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 ::AePageObjects::Element
122
- # latitude() # -> instance of ::AePageObjects::Element
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], ::AePageObjects::Collection)
139
+ ensure_class_for_param!(:is, options[:is], Collection)
140
140
  else
141
- options[:is] = ::AePageObjects::Collection
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(::AePageObjects::Form, &block)
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) || ::AePageObjects::Element
186
+ klass = options.delete(:is) || Element
187
187
 
188
188
  if block_given?
189
189
  Class.new(klass, &block)
@@ -26,7 +26,7 @@ module AePageObjects
26
26
 
27
27
  def from(from_mod)
28
28
  until from_mod == Object
29
- if from_mod < AePageObjects::Universe
29
+ if from_mod < Universe
30
30
  return from_mod.page_objects_site_class.instance
31
31
  end
32
32
 
@@ -22,7 +22,7 @@ module AePageObjects
22
22
  class << self
23
23
  private
24
24
  def site
25
- @site ||= AePageObjects::Site.from(self)
25
+ @site ||= Site.from(self)
26
26
  end
27
27
  end
28
28
  end
@@ -6,7 +6,7 @@ module AePageObjects
6
6
  end
7
7
 
8
8
  def load
9
- Waiter.wait_for do
9
+ Waiter.wait_until do
10
10
  @query.conditions.each do |document_condition|
11
11
  if document = @strategy.load_document_with_condition(document_condition)
12
12
  return document
@@ -20,7 +20,7 @@ module AePageObjects
20
20
  @document ||= begin
21
21
  node = self.parent
22
22
 
23
- until node.is_a?(::AePageObjects::Document)
23
+ until node.is_a?(Document)
24
24
  node = node.parent
25
25
  end
26
26
 
@@ -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
- Waiter.wait_for do
23
- inst = presence
24
- !! inst && inst.visible?
25
- end
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
- Waiter.wait_for do
30
- inst = presence
31
- inst.nil? || ! inst.visible?
32
- end
34
+ hidden?
33
35
  end
34
36
 
35
37
  def present?
36
- wait_for_presence
38
+ wait_until_present
37
39
  true
38
40
  rescue ElementNotPresent
39
41
  false
40
42
  end
41
43
 
42
- def not_present?
43
- wait_for_absence
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 wait_for_presence(timeout = nil)
56
- is_present = Waiter.wait_for(timeout) do
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 wait_for_absence(timeout = nil)
66
- is_absent = Waiter.wait_for(timeout) do
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 ElementNotPresent < Error
16
+ class ElementExpectationError < Error
17
17
  end
18
18
 
19
- class ElementNotAbsent < Error
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
@@ -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 AePageObjects::LoadingElementFailed
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 AePageObjects::LoadingPageFailed
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 AePageObjects::LoadingElementFailed
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.wait_for(wait_time = nil, &block)
4
- seconds_to_wait = wait_time || Capybara.default_wait_time
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
@@ -1,3 +1,3 @@
1
1
  module AePageObjects
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  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.2.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-05 00:00:00.000000000 Z
11
+ date: 2014-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara