ferrum-har 0.1.4 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ece6969fb3a3135a534510dbbee3a94544dfceaaebbf7ffdf2ca3b7ef9483a0c
4
- data.tar.gz: f1feb7448c4b4cd86b823e22f433f650bcbe7f2bae13b68668d35efaebc427a9
3
+ metadata.gz: 90c64095f327010a5364542de46bdb7eb2b5af3bbb401b0d643438900311c8ea
4
+ data.tar.gz: b53a43f0a6198c95cb20968ba4bd941ac8b085484e4592bc5853a72716a29043
5
5
  SHA512:
6
- metadata.gz: 6f60149634aababca262378cf044e8ffdd9c4dd0f6e34556ce336d3f50aec819ff43a7aea21cac26e30fa8cb7b820cb964d7a9ae9538d22c38c2a1c2d38582b2
7
- data.tar.gz: 21cdba221d68c0ae8eebb2ab4d915b33f17d4c9d4058110101a94729ece0bd95080e99d5ddd55943c6ff604e3c31901199c6d54e0c11172d1d8460241c4169e0
6
+ metadata.gz: fcf185fd1cd4b579fc0a1a2a57169285f7333f189eb8eeebd11d61202a8fc797bcce03db925e522dfa381f83f84038ce9b41fdced0957e7d8a4af3477fb88581
7
+ data.tar.gz: 951491f82275957ad30ea99a8e50f07867388744173e360f887558259bc6a252cffa2e96d99f2eb3ae8ee16b93c93ce1b44ce186a49093b6110acbff7dc4ea89
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  ferrum-har
2
2
  ================
3
3
 
4
- [![Gem Version](https://img.shields.io/gem/v/ferrum-har?color=green)](https://img.shields.io/gem/v/ferrum-har?color=green)
4
+ [![Gem Version](https://img.shields.io/gem/v/ferrum-har?color=green)](https://rubygems.org/gems/ferrum-har)
5
+ [![specs workflow](https://github.com/hlascelles/ferrum-har/actions/workflows/specs.yml/badge.svg)](https://github.com/hlascelles/ferrum-har/actions)
6
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
7
 
6
8
  [ferrum-har](https://github.com/hlascelles/ferrum-har) is a gem that adds the ability to capture
7
9
  [HAR](https://en.wikipedia.org/wiki/HAR_(file_format)) files while running tests
@@ -15,6 +17,17 @@ Add ferrum-har to your Gemfile and `bundle install`:
15
17
  gem "ferrum-har"
16
18
  ```
17
19
 
20
+ Since version 1.0, we have had to support [a change](https://developer.chrome.com/blog/extension-news-june-2025#deprecations)
21
+ to the way Chrome handles extensions. You must
22
+ use Chrome Testing to use ferrum-har. A rake task is provided to help you download a chrome binary.
23
+ It will put it in a folder called
24
+
25
+ ```bash
26
+ bundle exec rake chrome:install
27
+ ```
28
+
29
+ Alternatively you can use the ENV `BROWSER_PATH` to point to the binary location.
30
+
18
31
  ## Usage
19
32
 
20
33
  Use [ferrum](https://github.com/rubycdp/ferrum) as normal and call the `har` method on
@@ -11,6 +11,22 @@ module Ferrum
11
11
  super.tap do |options|
12
12
  check_har_related_browser_options(options)
13
13
  end
14
+
15
+ @path = ENV["BROWSER_PATH"] ||
16
+ begin
17
+ # Find the one in the temp download dir.
18
+ Dir.glob(".chrome-for-testing/*/chrome-linux64/chrome").max_by { |p|
19
+ Gem::Version.new(p.split("/")[1])
20
+ }
21
+ end
22
+
23
+ return if @path
24
+
25
+ raise <<~ERR
26
+ Browser path not found. Please set BROWSER_PATH environment variable, or trigger a download of Chrome Testing by using:
27
+
28
+ bundle exec rake chrome:install
29
+ ERR
14
30
  end
15
31
 
16
32
  private def check_har_related_browser_options(options)
@@ -10,6 +10,8 @@ module Ferrum
10
10
  # We have to remove the "disable-extensions" option from the default browser extension
11
11
  # list because the ferrum-har gem requires an (internal) extension to work.
12
12
  .except("disable-extensions")
13
+ # At some point past v134 this stopped extensions loading properly in the first tab.
14
+ .except("no-startup-window")
13
15
  .merge(
14
16
  "auto-open-devtools-for-tabs" => nil, # Chrome devtools must be open to invoke getHAR
15
17
  "load-extension" => "#{Ferrum::Har::GEM_DIR}/extension", # Extension that gets the HAR
@@ -12,7 +12,7 @@ module Ferrum
12
12
  def har
13
13
  network.wait_for_idle
14
14
  execute("document.ferrumHarRequested = true;")
15
- base64_encoded_har = Ferrum::Utils::Attempt.with_retry(
15
+ har_hash_result = Ferrum::Utils::Attempt.with_retry(
16
16
  errors: [HarNotReadyError],
17
17
  # 10 seconds
18
18
  max: 20,
@@ -21,13 +21,18 @@ module Ferrum
21
21
  found = evaluate("document.ferrumHar;")
22
22
  raise HarNotReadyError unless found
23
23
 
24
- found
24
+ inlined_har = Base64.decode64(found)
25
+ har_hash = JSON.parse(inlined_har)
26
+ raise HarNotReadyError, "Result does not appear to be a HAR" unless har_hash.key?("log")
27
+
28
+ entries = har_hash.dig("log", "entries")
29
+ # If entries is nil or empty, the HAR is not ready yet.
30
+ raise HarNotReadyError if entries.nil? || entries.empty?
31
+
32
+ har_hash
25
33
  end
26
- inlined_har = Base64.decode64(base64_encoded_har)
27
- har_hash = JSON.parse(inlined_har)
28
- raise "Result does not appear to be a HAR" unless har_hash.key?("log")
29
34
 
30
- JSON.pretty_generate(har_hash)
35
+ JSON.pretty_generate(har_hash_result)
31
36
  end
32
37
  end
33
38
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ferrum
4
4
  module Har
5
- VERSION = "0.1.4"
5
+ VERSION = "1.0.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ferrum-har
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Lascelles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-24 00:00:00.000000000 Z
11
+ date: 2025-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: selenium_chrome_helper
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Rubygem to convert ferrum traffic to HAR files
42
56
  email:
43
57
  - harry@harrylascelles.com
@@ -74,14 +88,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
74
88
  requirements:
75
89
  - - ">="
76
90
  - !ruby/object:Gem::Version
77
- version: '3.0'
91
+ version: '0'
78
92
  required_rubygems_version: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  requirements: []
84
- rubygems_version: 3.5.3
98
+ rubygems_version: 3.5.22
85
99
  signing_key:
86
100
  specification_version: 4
87
101
  summary: Rubygem to convert ferrum traffic to HAR files