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 +4 -4
- data/CHANGELOG.md +1 -5
- data/Gemfile.lock +1 -1
- data/README.md +0 -2
- data/lib/capybara/wait_image/version.rb +1 -1
- data/lib/capybara/wait_image.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 751271010568320c7f321c0eb418faea34735be6e97f2c9c40185c6a2133080c
|
4
|
+
data.tar.gz: 7ce810c330ddf5e65e05fbd8be00978013aeb17b1dd7933dd79eb4ff2c8ca219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b5ffe15ee16cfe88cad4fcfbe4d024393cd4062e2f308e331eca0003f9afeecb2060d2b0db5ab4590fffc3c30127e3799b9eb640f1913bbe20818fdb18f4b3
|
7
|
+
data.tar.gz: 55c260e365a04d29529a66fc85b5c6d904a919dd868aa287fbfb9601d69ee683c1dbefa8ef5133527e3cff5451f216d7c70dad00403302c9e0001172cb891b32
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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:
|
data/lib/capybara/wait_image.rb
CHANGED
@@ -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
|
23
|
-
_logger.debug "[capybara-wait_image]
|
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.
|
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-
|
11
|
+
date: 2023-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|