ae_page_objects 4.0.1 → 4.4.0.pre.rc.1

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
- SHA1:
3
- metadata.gz: db1d397fb998ff6d6fce4f99c5c23903023dd1f6
4
- data.tar.gz: 8adbae2a2d9c88068b591e901e46568a872fbfa0
2
+ SHA256:
3
+ metadata.gz: a81fd3e14e49322c4e0ca92ce91305800f7edde065a25f78776cadbeb1192de9
4
+ data.tar.gz: 3bacbc5553b90bc2e43ffec38a2d2f4de72544f0ec0c3932df0f0901852877e7
5
5
  SHA512:
6
- metadata.gz: 7dce44727da3a23632fc2d796a8aca93cb560ef9d6cceff31b7b22b14bb919644d09add3d41f61c0d904605c9c26fa7d773bd213f0a9b5489946ebcd302bb14a
7
- data.tar.gz: 80be52c061e4fb9e3c23e03e0b681ae65d262569ca76a19d60bab6e2e70c5f2359ad20c86ff7cbff46a7b347681cdb1459272ef87ac6870469ccb5fdc4968c07
6
+ metadata.gz: 8b01d530f561624b31f84d6cd50c79380c553e08df964c34cd2316ee2923b913853f3eb69f5dfbb446ef77ab81f6b515b31739dab4615fd452b60d0e735fe939
7
+ data.tar.gz: c6495b4e601622233ce5f9bed97612fb51cd37a0db4d9c577637c3babad5caec4418a5ab1d26f8b75c3061200d1d5a51fd181af99f66c43534d4267ec87dd488
@@ -16,7 +16,7 @@ module AePageObjects
16
16
  autoload :Checkbox, 'ae_page_objects/elements/checkbox'
17
17
 
18
18
  class << self
19
- attr_accessor :default_router
19
+ attr_accessor :default_router, :time_keeper
20
20
 
21
21
  def browser
22
22
  @browser ||= begin
@@ -45,7 +45,7 @@ module AePageObjects
45
45
  result = call_wait_until_block(error_message, &block)
46
46
  else
47
47
  seconds_to_wait ||= default_max_wait_time
48
- start_time = Time.now
48
+ start_time = AePageObjects.time_keeper.now
49
49
 
50
50
  # In an effort to avoid flakiness, Capybara waits, rescues errors, reloads nodes, and
51
51
  # retries.
@@ -71,7 +71,7 @@ module AePageObjects
71
71
  errors += [WaitTimeoutError]
72
72
  raise e unless errors.include?(e.class)
73
73
 
74
- delay = seconds_to_wait - (Time.now - start_time)
74
+ delay = seconds_to_wait - (AePageObjects.time_keeper.now - start_time)
75
75
 
76
76
  if delay <= 0
77
77
  # Raising the WaitTimeoutError in the rescue block ensures that Ruby attaches
@@ -80,7 +80,7 @@ module AePageObjects
80
80
  end
81
81
 
82
82
  sleep(0.05)
83
- raise FrozenInTime, "Time appears to be frozen" if Time.now == start_time
83
+ raise FrozenInTime, "Time appears to be frozen" if AePageObjects.time_keeper.now == start_time
84
84
 
85
85
  retry
86
86
  end
@@ -106,3 +106,4 @@ end
106
106
 
107
107
  require 'ae_page_objects/core/basic_router'
108
108
  AePageObjects.default_router = AePageObjects::BasicRouter.new
109
+ AePageObjects.time_keeper = Time
@@ -32,7 +32,25 @@ module AePageObjects
32
32
  full_path = router.generate_path(path, *args)
33
33
  raise PathNotResolvable, "#{self.name} not visitable via #{paths.first}(#{args.inspect})" unless full_path
34
34
 
35
- Capybara.current_session.visit(full_path)
35
+ load_retries = 0
36
+ begin
37
+ Capybara.current_session.visit(full_path)
38
+ rescue Net::ReadTimeout
39
+ # A Net::ReadTimeout can occur when the current session was already in the progress of loading
40
+ # a page. This is fairly common and happens in situations like below:
41
+ # 1. the test performs an action that causes the page to reload
42
+ # 2. an assertion is made on the new page
43
+ # 3. the test then loads a different page
44
+ # Its possible for the assertion in #2 above to happen before the page is fully loaded, in which
45
+ # case the page load in #3 can fail with Net::ReadTimeout.
46
+ # In this situation the easiest thing to do is to retry
47
+ if load_retries < 3
48
+ load_retries += 1
49
+ retry
50
+ else
51
+ raise
52
+ end
53
+ end
36
54
 
37
55
  new
38
56
  end
@@ -41,7 +41,19 @@ module AePageObjects
41
41
  end
42
42
 
43
43
  def size
44
- node.all(:xpath, item_xpath, options.merge(wait: false)).size
44
+ #
45
+ # In some cases when #size is called while the DOM is updating, Capybara
46
+ # will catch (and swallow) underlying exceptions such as
47
+ # `Selenium::WebDriver::Error::StaleElementReferenceError`.
48
+ # When this happens it will wait up to the max wait time, which can cause
49
+ # issues for `AePageObjects.wait_until` blocks.
50
+ #
51
+ # To prevent this issue the #all and #size calls are made with the Capybara
52
+ # wait time set to 0.
53
+ #
54
+ Capybara.using_wait_time(0) do
55
+ node.all(:xpath, item_xpath, options).size
56
+ end
45
57
  end
46
58
 
47
59
  def last
@@ -133,12 +133,12 @@ module AePageObjects
133
133
  private
134
134
 
135
135
  def recognizer
136
- @recognizer ||= case ::Rails.version
137
- when /\A3\.[01]/
136
+ @recognizer ||= case ::Rails.gem_version
137
+ when Gem::Requirement.new('>= 3.0', '< 3.2')
138
138
  Recognizer::Rails3.new
139
- when /\A3\.2/
139
+ when Gem::Requirement.new('~> 3.2')
140
140
  Recognizer::Rails32.new
141
- when /\A(4\.[012]|5\.0)/
141
+ when Gem::Requirement.new('>= 4.0', '< 7.0')
142
142
  Recognizer::Rails4Plus.new
143
143
  else
144
144
  warn "[WARNING]: AePageObjects is not tested against Rails #{::Rails.version} and may behave in an undefined manner."
@@ -6,13 +6,13 @@ module AePageObjects
6
6
  end
7
7
 
8
8
  def using_wait_time
9
- start_time = Time.now
9
+ start_time = AePageObjects.time_keeper.now
10
10
  @wait_time = [@wait_time, @max_time].min
11
11
  Capybara.using_wait_time(@wait_time) do
12
12
  yield
13
13
  end
14
14
  ensure
15
- if Time.now - start_time > @wait_time
15
+ if AePageObjects.time_keeper.now - start_time > @wait_time
16
16
  @wait_time *= 2
17
17
  end
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module AePageObjects
2
- VERSION = '4.0.1'.freeze
2
+ VERSION = '4.4.0.pre.rc.1'.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: 4.0.1
4
+ version: 4.4.0.pre.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-07 00:00:00.000000000 Z
11
+ date: 2020-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -64,7 +64,7 @@ homepage: http://github.com/appfolio/ae_page_objects
64
64
  licenses:
65
65
  - MIT
66
66
  metadata: {}
67
- post_install_message:
67
+ post_install_message:
68
68
  rdoc_options: []
69
69
  require_paths:
70
70
  - lib
@@ -75,13 +75,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
75
75
  version: 2.2.5
76
76
  required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ">="
78
+ - - ">"
79
79
  - !ruby/object:Gem::Version
80
- version: '0'
80
+ version: 1.3.1
81
81
  requirements: []
82
- rubyforge_project:
83
- rubygems_version: 2.5.2
84
- signing_key:
82
+ rubygems_version: 3.1.2
83
+ signing_key:
85
84
  specification_version: 4
86
85
  summary: Capybara Page Objects pattern
87
86
  test_files: []