capybara-wait_image 0.3.0 → 0.3.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
2
  SHA256:
3
- metadata.gz: d5c10cf9ec96ac3fac24de6bce81a52659ec13a055e2dbeb9bc309e9649978f3
4
- data.tar.gz: 75fe4376400c092a76383b7d0571c27296bffe8f991679302a130684bc02db34
3
+ metadata.gz: 751271010568320c7f321c0eb418faea34735be6e97f2c9c40185c6a2133080c
4
+ data.tar.gz: 7ce810c330ddf5e65e05fbd8be00978013aeb17b1dd7933dd79eb4ff2c8ca219
5
5
  SHA512:
6
- metadata.gz: fe2ec92fee1fd86b0745b2611f7ff8f66c81dbe39cf26ee2fa0450b9ef77924bf00b0e75de19538a6b630de142b1614739ac219d2acf96c4ecf0e66b98db6a87
7
- data.tar.gz: 18a9edd98eca4a49a7d2edd51808411e442ab854e5a77f035adc26d63a57ffcfba1eeb14662231b2e24cb63833b59d3a32749cd91f0769e5644ddbfe667100a9
6
+ metadata.gz: 18b5ffe15ee16cfe88cad4fcfbe4d024393cd4062e2f308e331eca0003f9afeecb2060d2b0db5ab4590fffc3c30127e3799b9eb640f1913bbe20818fdb18f4b3
7
+ data.tar.gz: 55c260e365a04d29529a66fc85b5c6d904a919dd868aa287fbfb9601d69ee683c1dbefa8ef5133527e3cff5451f216d7c70dad00403302c9e0001172cb891b32
data/CHANGELOG.md CHANGED
@@ -1,5 +1 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2022-08-24
4
-
5
- - Initial release
1
+ See: https://github.com/willnet/capybara-wait_image/releases
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capybara-wait_image (0.3.0)
4
+ capybara-wait_image (0.3.1)
5
5
  capybara (~> 3.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -4,8 +4,6 @@ The main cause of flaky tests in E2E tests using a browser is a click error caus
4
4
 
5
5
  By adding this gem, the test will wait for the image to be displayed just before each click, hover, etc, thus improving the reliability of the test.
6
6
 
7
- Currently, this gem supports only RSpec, so if you want to use it for other than RSpec, please submit a pull request.
8
-
9
7
  ## Installation
10
8
 
11
9
  Install the gem and add to the application's Gemfile by executing:
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capybara
4
4
  module WaitImage
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
6
6
  end
7
7
  end
@@ -6,6 +6,18 @@ require "capybara"
6
6
  module Capybara
7
7
  # Wait for image to load automatically
8
8
  module WaitImage
9
+ def _stale_errors
10
+ return @_stale_errors if defined? @_stale_errors
11
+
12
+ @_stale_errors = []
13
+ if defined? ::Selenium::WebDriver::Error::StaleElementReferenceError
14
+ @_stale_errors << ::Selenium::WebDriver::Error::StaleElementReferenceError
15
+ end
16
+ @_stale_errors << ::Ferrum::NodeNotFoundError if defined? ::Ferrum::NodeNotFoundError
17
+ @_stale_errors << ::Capybara::Cuprite::ObsoleteNode if defined? ::Capybara::Cuprite::ObsoleteNode
18
+ @_stale_errors
19
+ end
20
+
9
21
  def _wait_for_image_loading # rubocop:disable Metrics/MethodLength
10
22
  Timeout.timeout(Capybara.default_max_wait_time) do
11
23
  sleep 0.5 until evaluate_script(<<~JS)
@@ -19,8 +31,8 @@ module Capybara
19
31
  _logger.debug "[capybara-wait_image]Timeout::Error"
20
32
  rescue Capybara::NotSupportedByDriverError
21
33
  # It comes here when you run it in rack-test, but you can ignore it
22
- rescue ::Selenium::WebDriver::Error::StaleElementReferenceError
23
- _logger.debug "[capybara-wait_image]Selenium::WebDriver::Error::StaleElementReferenceError"
34
+ rescue *_stale_errors
35
+ _logger.debug "[capybara-wait_image]Stale Error"
24
36
  reload
25
37
  _wait_for_image_loading
26
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-wait_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - willnet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-19 00:00:00.000000000 Z
11
+ date: 2023-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara