ferrum-har 1.0.1 → 1.0.2

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: 90c64095f327010a5364542de46bdb7eb2b5af3bbb401b0d643438900311c8ea
4
- data.tar.gz: b53a43f0a6198c95cb20968ba4bd941ac8b085484e4592bc5853a72716a29043
3
+ metadata.gz: ae66c86e06740c5afb98f7633cbf466c71935fd406de55f196ec0c5a92668ed2
4
+ data.tar.gz: 5da78a09c0f1b07987c9497edaf20f542d0b37e827d944c936a72ad019b44b5e
5
5
  SHA512:
6
- metadata.gz: fcf185fd1cd4b579fc0a1a2a57169285f7333f189eb8eeebd11d61202a8fc797bcce03db925e522dfa381f83f84038ce9b41fdced0957e7d8a4af3477fb88581
7
- data.tar.gz: 951491f82275957ad30ea99a8e50f07867388744173e360f887558259bc6a252cffa2e96d99f2eb3ae8ee16b93c93ce1b44ce186a49093b6110acbff7dc4ea89
6
+ metadata.gz: cc7dd1f84801f144725b561ed64a0a3c5d54c5b165c053da47a407b9682bcac4cfc62ba7294eea2eef8160744e17c54f845f926fb43dc00f03cef347e3ef511f
7
+ data.tar.gz: 6d793bb6ea3ff0df10a1b1b5c7576a546a91a5b00108c83491952c768b3e94f32b369ad8666ce8ed7f72ed4f940b7927730ee1605b3f5f0883936504c9e67a63
data/README.md CHANGED
@@ -18,15 +18,18 @@ gem "ferrum-har"
18
18
  ```
19
19
 
20
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
21
+ to the way Chrome handles extensions which means you must use [Chrome For Testing](https://developer.chrome.com/blog/chrome-for-testing)
22
+ to use ferrum-har. This involves downloading that Chrome version as a binary.
23
+
24
+ A rake task is provided to help you download the binary, supplied by the [selenium_chrome_helper](https://github.com/pepito2k/selenium_chrome_helper) gem.
25
+ It will put it in a folder called `.chrome-for-testing` in your project root. To execute it, run:
24
26
 
25
27
  ```bash
26
28
  bundle exec rake chrome:install
27
29
  ```
28
30
 
29
- Alternatively you can use the ENV `BROWSER_PATH` to point to the binary location.
31
+ Alternatively you can use the ENV `BROWSER_PATH` to point to the binary location. Note, you can't
32
+ point it to your standard Chrome installation, it must be the Chrome Testing binary.
30
33
 
31
34
  ## Usage
32
35
 
@@ -74,10 +77,26 @@ For further reading, a full list of Chrome switches can be found
74
77
  `ferrum-har` uses [semantic versioning](https://semver.org/), so major version changes will usually
75
78
  require additional actions to be taken upgrading from one major version to another.
76
79
 
80
+ ## Persistent Chrome profile
81
+
82
+ You can specify the ENV `FERRUM_HAR_BROWSER_CONFIG_DIR` to point to a persistent Chrome profile dir
83
+ between runs. This will allow you to do slow setup once, then do fast reruns of your tests. Note
84
+ this should only be used for development purposes, your tests should not rely on a persistent
85
+ profile in CI.
86
+
87
+ See the [spec/acceptance/test.rb](https://github.com/hlascelles/ferrum-har/blob/master/spec/acceptance/test.rb) for
88
+ an example of how to use this.
89
+
90
+ ## Single file example
91
+
92
+ A single file example of how to use `ferrum-har` can be found in [spec/acceptance/test.rb](https://github.com/hlascelles/ferrum-har/blob/master/spec/acceptance/test.rb).
93
+
77
94
  ## Changelog
78
95
 
79
96
  A full changelog can be found here: [CHANGELOG.md](https://github.com/hlascelles/ferrum-har/blob/master/CHANGELOG.md)
80
97
 
98
+ ```
99
+
81
100
  ## Further work
82
101
 
83
102
  Some ideas for improvements.
@@ -6,19 +6,19 @@ module Ferrum
6
6
  class ConfigurationError < RuntimeError
7
7
  end
8
8
 
9
+ class << self
10
+ def find_chrome_for_testing_binary
11
+ Dir.glob(".chrome-for-testing/**/chrome").max_by { |p| Gem::Version.new(p.split("/")[1]) }
12
+ end
13
+ end
14
+
9
15
  module BrowserCommandExtension
10
16
  def merge_options
11
17
  super.tap do |options|
12
18
  check_har_related_browser_options(options)
13
19
  end
14
20
 
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
21
+ @path = ENV["BROWSER_PATH"] || Ferrum::Har.find_chrome_for_testing_binary
22
22
 
23
23
  return if @path
24
24
 
@@ -6,9 +6,11 @@ module Ferrum
6
6
  module Har
7
7
  module OptionsExtension
8
8
  def merge_default(flags, options)
9
- super
10
- # We have to remove the "disable-extensions" option from the default browser extension
11
- # list because the ferrum-har gem requires an (internal) extension to work.
9
+ original_result = super
10
+ # We have to remove the "disable-extensions" option from the default browser extension
11
+ # list because the ferrum-har gem requires an (internal) extension to work.
12
+ changed =
13
+ original_result
12
14
  .except("disable-extensions")
13
15
  # At some point past v134 this stopped extensions loading properly in the first tab.
14
16
  .except("no-startup-window")
@@ -16,6 +18,16 @@ module Ferrum
16
18
  "auto-open-devtools-for-tabs" => nil, # Chrome devtools must be open to invoke getHAR
17
19
  "load-extension" => "#{Ferrum::Har::GEM_DIR}/extension", # Extension that gets the HAR
18
20
  )
21
+
22
+ # To get a custom config dir to work, we have to remove the "disable-web-security" option
23
+ if ENV["FERRUM_HAR_BROWSER_CONFIG_DIR"]
24
+ changed =
25
+ changed
26
+ .except("disable-web-security")
27
+ .merge("user-data-dir" => ENV["FERRUM_HAR_BROWSER_CONFIG_DIR"])
28
+ end
29
+
30
+ changed
19
31
  end
20
32
  end
21
33
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ferrum
4
4
  module Har
5
- VERSION = "1.0.1"
5
+ VERSION = "1.0.2"
6
6
  end
7
7
  end
data/lib/ferrum/har.rb CHANGED
@@ -7,6 +7,13 @@ require "ferrum/har/command_extension"
7
7
  require "ferrum/har/page_extension"
8
8
  require "ferrum/har/options_extension"
9
9
 
10
+ # The chrome downloader helper
11
+ if Gem.loaded_specs.key?("rake")
12
+ require "selenium_chrome_helper"
13
+ require "rake"
14
+ load "tasks/install.rake" # Load the chrome testing downloader task
15
+ end
16
+
10
17
  module Ferrum
11
18
  module Har
12
19
  GEM_DIR = File.expand_path("../..", __dir__)
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Lascelles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-17 00:00:00.000000000 Z
11
+ date: 2025-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64