ae_page_objects 4.0.0.pre3 → 4.0.0.pre4

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: c74b68a1c39113aa789cd3630e1c3502992945a2
4
- data.tar.gz: 779ef880d3bb5d81745b8683173f57ab40564c32
3
+ metadata.gz: 1b784c0522c2e291327f19338dadb8c97a7ab028
4
+ data.tar.gz: da4ea7af94b30de00765d0bc781fbacdf466ba02
5
5
  SHA512:
6
- metadata.gz: f661d71759e365cbbef81c5f0cb03448d17a237ca11586d3b45e4103d6cb4b276c42f4046097e792505dd52945327f81d15ee01b47ab8e58f12f1e78edaff8dd
7
- data.tar.gz: cb1ba032cde6992819945287408a55d249bf1fa9a8a11c19f8aff4d9f5c42070971b7a461701522cc804786e0bf04d18055709a56dcc6ff896804f35a866f121
6
+ metadata.gz: 331e3411ccb7f9a2b27f32ec7f3958f9fe3fe3390edc96064fc5ebc9929bcea732f4902a614dc93d7c655b21fa1d24bdb1804597c40988a80bcf495c708f4047
7
+ data.tar.gz: f9e55883730b956970ccd80dde9c72f7c25457f9769b5184697e16a4969322d103a2245aad800b949b89968acf3b3f440f79e985a435ae2f3c4d8dfbf272673c
@@ -67,6 +67,17 @@ module AePageObjects
67
67
  self
68
68
  end
69
69
 
70
+ def reload(timeout: nil)
71
+ Capybara.current_session.driver.execute_script <<-SCRIPT
72
+ document.body.classList.add('reloading');
73
+ location.reload(true);
74
+ SCRIPT
75
+
76
+ element('body.reloading').wait_until_absent(timeout)
77
+ ensure_loaded!
78
+ self
79
+ end
80
+
70
81
  private
71
82
 
72
83
  def ensure_loaded!
@@ -74,9 +74,11 @@ module AePageObjects
74
74
  end
75
75
 
76
76
  def reload_descendents
77
+ # Reload the parent first, traversing up until we hit the document
77
78
  parent.reload_descendents if parent.respond_to?(:reload_descendents)
78
- @node = scoped_node
79
- @stale = false
79
+
80
+ # Tell the capybara node to reload
81
+ @node.reload
80
82
  ensure_loaded!
81
83
  end
82
84
 
@@ -100,10 +100,21 @@ module AePageObjects
100
100
 
101
101
  implicit_element.__send__(name, *args, &block)
102
102
  rescue Selenium::WebDriver::Error::StaleElementReferenceError
103
+ #
103
104
  # A StaleElementReferenceError can occur when a selenium node is referenced but is no longer attached to the DOM.
104
105
  # In this case we need to work our way up the element tree to make sure we are referencing the latest DOM nodes.
105
- implicit_element.reload_descendents
106
- retry
106
+ #
107
+ # In some cases we get this exception and cannot recover from it. This usually occurs when code outside of
108
+ # ae_page_objects calls capybara queries directly. In these cases we need to raise the original exception
109
+ #
110
+ @retry_count ||= 0
111
+ @retry_count += 1
112
+ if @retry_count < 5
113
+ implicit_element.reload_descendents
114
+ retry
115
+ else
116
+ raise
117
+ end
107
118
  end
108
119
 
109
120
  def respond_to?(*args)
@@ -1,3 +1,3 @@
1
1
  module AePageObjects
2
- VERSION = '4.0.0.pre3'.freeze
2
+ VERSION = '4.0.0.pre4'.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.0.pre3
4
+ version: 4.0.0.pre4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donnie Tognazzini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-01 00:00:00.000000000 Z
11
+ date: 2018-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara