selenium_download_helper 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -7
- data/lib/selenium_download_helper/errors.rb +12 -0
- data/lib/selenium_download_helper/version.rb +1 -1
- data/lib/selenium_download_helper.rb +7 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5467dad132759192c6e70376b7c2f7cf5432acdaa1c7448026c28eb64251b7e9
|
4
|
+
data.tar.gz: 5380c0df4b66f7643fc118f7e69be0384651e1c98fc934189967a8317ca61439
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d50cafa8b05cb778c76f7d3d727cb8a42bb3bceb6e234f6450001e5d9e8389a41574e34c5e8bf01232d80f26befa595e96d6b99dd52d61b62c7fc4cf6de11d43
|
7
|
+
data.tar.gz: c76971e08269761e80b6a33b5dc51787328a6678c83f79906405992121d655c7e3846c01756ac8ff73d5528031aece3cb9b9b4471e78208a9dfeb4b94250e1f8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
selenium_download_helper (1.
|
4
|
+
selenium_download_helper (1.2.0)
|
5
5
|
rails (>= 7.0)
|
6
6
|
selenium-webdriver
|
7
7
|
|
@@ -119,12 +119,8 @@ GEM
|
|
119
119
|
net-smtp (0.5.0)
|
120
120
|
net-protocol
|
121
121
|
nio4r (2.7.3)
|
122
|
-
nokogiri (1.
|
123
|
-
mini_portile2 (~> 2.8.
|
124
|
-
racc (~> 1.4)
|
125
|
-
nokogiri (1.16.7-arm64-darwin)
|
126
|
-
racc (~> 1.4)
|
127
|
-
nokogiri (1.16.7-x86_64-darwin)
|
122
|
+
nokogiri (1.14.3)
|
123
|
+
mini_portile2 (~> 2.8.0)
|
128
124
|
racc (~> 1.4)
|
129
125
|
psych (5.1.2)
|
130
126
|
stringio
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SeleniumDownloadHelper
|
2
|
+
class TimeoutError < StandardError
|
3
|
+
def initialize(error, download_path)
|
4
|
+
@download_path = download_path
|
5
|
+
super("#{error.message}\nDownloaded files:\n#{downloaded_files.join("\n")}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def downloaded_files
|
9
|
+
Dir[File.join(@download_path, '*')]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -5,10 +5,14 @@ require 'fileutils'
|
|
5
5
|
require 'selenium-webdriver'
|
6
6
|
require 'active_support/concern'
|
7
7
|
require_relative 'selenium_download_helper/version'
|
8
|
+
require_relative 'selenium_download_helper/errors'
|
8
9
|
|
9
10
|
module SeleniumDownloadHelper
|
10
11
|
extend ActiveSupport::Concern
|
11
12
|
|
13
|
+
TEMPORARY_DOWNLOAD_FILENAME_PATTERN = /(\.crdownload|\/downloads.html)$/
|
14
|
+
|
15
|
+
|
12
16
|
included do
|
13
17
|
after(:all) do
|
14
18
|
FileUtils.rm_rf(base_download_dir)
|
@@ -21,6 +25,8 @@ module SeleniumDownloadHelper
|
|
21
25
|
yield
|
22
26
|
Selenium::WebDriver::Wait.new(timeout: timeout, interval: interval).until { downloaded?(download_path, filename:) }
|
23
27
|
downloaded_files(download_path, filename:).then { |files| all ? files : files.first }
|
28
|
+
rescue Selenium::WebDriver::Error::TimeoutError => e
|
29
|
+
raise TimeoutError.new(e, download_path)
|
24
30
|
end
|
25
31
|
|
26
32
|
private
|
@@ -42,6 +48,6 @@ module SeleniumDownloadHelper
|
|
42
48
|
|
43
49
|
def downloaded?(download_path, filename: nil)
|
44
50
|
files = downloaded_files(download_path, filename:)
|
45
|
-
files.map(&:to_s).grep(
|
51
|
+
files.map(&:to_s).grep(TEMPORARY_DOWNLOAD_FILENAME_PATTERN).none? && files.any?
|
46
52
|
end
|
47
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium_download_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki77
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- bin/console
|
59
59
|
- bin/setup
|
60
60
|
- lib/selenium_download_helper.rb
|
61
|
+
- lib/selenium_download_helper/errors.rb
|
61
62
|
- lib/selenium_download_helper/version.rb
|
62
63
|
- selenium_download_helper.gemspec
|
63
64
|
homepage: https://github.com/SonicGarden/selenium_download_helper
|