ferrum-har 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -8
- data/lib/ferrum/har/options_extension.rb +20 -0
- data/lib/ferrum/har/version.rb +1 -1
- data/lib/ferrum/har.rb +5 -9
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d8d40ce71b743bf429c007041d4e1df81c0cf82b9765d8cf886249abf882543
|
4
|
+
data.tar.gz: 33c293040e516c1e28fc1ad31c95a8c6e43ed9509b2b773644efcfe0eca74d2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fa0a91fefc4e7a6c14b176257521e9c02941d420e6ad64e0e5681e1efd3b6121b97c33d685338176a0c8c2381213f994f6989fb92ae55f8e44ad68d99bffe4d
|
7
|
+
data.tar.gz: 2e93582b28d0c0ceb59638f3e92c0e3ef74178a27ba6d20d1a08b5578d55e091fefc709d14557abe07824cd778c05d8a97b278d79fd4ab9e62ac763842477f05
|
data/README.md
CHANGED
@@ -18,16 +18,13 @@ gem "ferrum-har"
|
|
18
18
|
## Usage
|
19
19
|
|
20
20
|
Use [ferrum](https://github.com/rubycdp/ferrum) as normal and call the `har` method on
|
21
|
-
the `page` (or `browser`) object.
|
22
|
-
by using the `Ferrum::Har::REQUIRED_BROWSER_OPTIONS` constant.
|
21
|
+
the `page` (or `browser`) object. Chrome must be used as the browser engine.
|
23
22
|
|
24
|
-
Note, the devtools window in Chrome will be opened for the duration of the ferrum
|
25
|
-
This is mandatory to obtain the HAR from Chrome.
|
23
|
+
Note, the devtools window in Chrome will be opened by ferrum-har for the duration of the ferrum
|
24
|
+
test run. This is mandatory to obtain the HAR from Chrome.
|
26
25
|
|
27
26
|
```ruby
|
28
|
-
browser = Ferrum::Browser.new
|
29
|
-
browser_options: Ferrum::Har::REQUIRED_BROWSER_OPTIONS,
|
30
|
-
)
|
27
|
+
browser = Ferrum::Browser.new
|
31
28
|
page = browser.create_page
|
32
29
|
page.go_to("https://www.bbc.co.uk")
|
33
30
|
|
@@ -53,7 +50,7 @@ One ramification of this is that the Chrome devtools must be open for the extens
|
|
53
50
|
|
54
51
|
To get the extension to be loaded we must pass some switches to the Chrome process via ferrum,
|
55
52
|
specifically the `--auto-open-devtools-for-tabs` and `--load-extension` switches. This is done
|
56
|
-
by
|
53
|
+
by ferrum-har automatically.
|
57
54
|
|
58
55
|
For further reading, a full list of Chrome switches can be found
|
59
56
|
[here](https://peter.sh/experiments/chromium-command-line-switches/).
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module is prepended to Ferrum::Browser::Options::Chrome to alter the default options so they
|
4
|
+
# work with the ferrum-har gem.
|
5
|
+
module Ferrum
|
6
|
+
module Har
|
7
|
+
module OptionsExtension
|
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.
|
12
|
+
.except("disable-extensions")
|
13
|
+
.merge(
|
14
|
+
"auto-open-devtools-for-tabs" => nil, # Chrome devtools must be open to invoke getHAR
|
15
|
+
"load-extension" => "#{Ferrum::Har::GEM_DIR}/extension", # Extension that gets the HAR
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/ferrum/har/version.rb
CHANGED
data/lib/ferrum/har.rb
CHANGED
@@ -1,23 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "ferrum"
|
4
|
+
require "ferrum/browser/options/chrome"
|
4
5
|
require "ferrum/har/version"
|
5
6
|
require "ferrum/har/page_extension"
|
7
|
+
require "ferrum/har/options_extension"
|
6
8
|
|
7
9
|
module Ferrum
|
8
10
|
module Har
|
9
11
|
GEM_DIR = File.expand_path("../..", __dir__)
|
10
|
-
REQUIRED_BROWSER_OPTIONS = {
|
11
|
-
"auto-open-devtools-for-tabs" => nil, # The chrome devtools must be open to invoke getHAR
|
12
|
-
"load-extension" => "#{Ferrum::Har::GEM_DIR}/extension", # The extension that gets the HAR
|
13
|
-
}.freeze
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
17
|
-
# We have to remove the "disable-extensions" option from the default browser extension list because
|
18
|
-
# the ferrum-har gem requires an (internal) extension to work.
|
19
|
-
Ferrum::Browser::Options::Chrome::DEFAULT_OPTIONS =
|
20
|
-
Ferrum::Browser::Options::Chrome::DEFAULT_OPTIONS.except("disable-extensions")
|
21
|
-
|
22
15
|
# Add the #har method to Ferrum::Page
|
23
16
|
Ferrum::Page.prepend(Ferrum::Har::PageExtension)
|
17
|
+
|
18
|
+
# Add the #merge_default method to Ferrum::Browser::Options::Chrome
|
19
|
+
Ferrum::Browser::Options::Chrome.prepend(Ferrum::Har::OptionsExtension)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ferrum-har
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Lascelles
|
@@ -11,7 +11,7 @@ cert_chain: []
|
|
11
11
|
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: base64
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: ferrum
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -47,6 +47,7 @@ extra_rdoc_files: []
|
|
47
47
|
files:
|
48
48
|
- README.md
|
49
49
|
- lib/ferrum/har.rb
|
50
|
+
- lib/ferrum/har/options_extension.rb
|
50
51
|
- lib/ferrum/har/page_extension.rb
|
51
52
|
- lib/ferrum/har/version.rb
|
52
53
|
homepage: https://github.com/hlascelles/ferrum-har
|