capybara-box 1.0.1 → 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/CHANGELOG.md +63 -24
- data/README.md +8 -3
- data/lib/capybara-box/base.rb +30 -18
- data/lib/capybara-box/helper.rb +8 -0
- data/lib/capybara-box/screenshot.rb +6 -2
- data/lib/capybara-box/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe208d8f8fb951f498d76fe53640da096df8c4d4e32c44e065b3e6eb240d1265
|
4
|
+
data.tar.gz: 99fcc0e8620c7d44f11783a36509781bd4ebb08da0565948dcd3972fab0af89b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05dc1e17050c6d4790914138d39cf0199824ca854ab8efbebf7f48a34206dd7c61894d2a5a94989605fe8e8172ac9f61519ce050b3791e34eb5cc8fb4ed6cadb
|
7
|
+
data.tar.gz: 82ee9c9d6a1a7cef8d80c9a3711c187d09365bf3c20e2039660c31fc79411c8070e933a984942932471cf8834fac816fee6e11b0608f755c93983a601ece4f33
|
data/CHANGELOG.md
CHANGED
@@ -1,41 +1,80 @@
|
|
1
|
-
|
1
|
+
# v1.2.0
|
2
2
|
|
3
|
-
|
4
|
-
- Registers driver name as symbol;
|
3
|
+
## Updates
|
5
4
|
|
6
|
-
|
5
|
+
- Avoids deprecated Selenium `:options`;
|
7
6
|
|
8
|
-
|
9
|
-
- Updated default arguments;
|
10
|
-
- Spec files now is excluded from gem pack;
|
7
|
+
# v1.1.2
|
11
8
|
|
12
|
-
|
13
|
-
- Capybara `load_selenium` is called before startup;
|
14
|
-
- Screenshot S3 feature now is configure only via ENV;
|
15
|
-
- Using new gem `webdrivers`;
|
9
|
+
## Fixes
|
16
10
|
|
17
|
-
-
|
18
|
-
|
11
|
+
- Avoid apply blank bin path;
|
12
|
+
- Avoid apply blank version;
|
19
13
|
|
20
|
-
|
14
|
+
# v1.1.1
|
21
15
|
|
22
|
-
|
16
|
+
## Fixes
|
23
17
|
|
24
|
-
|
18
|
+
- Removes default args that was avoiding screen render.
|
19
|
+
|
20
|
+
# v1.1.0
|
21
|
+
|
22
|
+
## Fixes
|
23
|
+
|
24
|
+
- S3 config activation;
|
25
|
+
|
26
|
+
## Updates
|
27
|
+
|
28
|
+
- Adds more default arguments;
|
29
|
+
|
30
|
+
# v1.0.1
|
31
|
+
|
32
|
+
## Fixes
|
33
|
+
|
34
|
+
- Registers driver name as symbol;
|
35
|
+
|
36
|
+
# v1.0.0
|
37
|
+
|
38
|
+
## Updates
|
39
|
+
|
40
|
+
- Updated default arguments;
|
41
|
+
- Spec files now is excluded from gem pack;
|
42
|
+
|
43
|
+
## Features
|
44
|
+
|
45
|
+
- Capybara `load_selenium` is called before startup;
|
46
|
+
- Screenshot S3 feature now is configure only via ENV;
|
47
|
+
- Using new gem `webdrivers`;
|
48
|
+
|
49
|
+
## Fixes
|
50
|
+
|
51
|
+
- Fix screenshot upload;
|
52
|
+
|
53
|
+
# v0.4.0
|
54
|
+
|
55
|
+
## Updates
|
56
|
+
|
57
|
+
- Selenium WebDriver deprecated message;
|
58
|
+
|
59
|
+
# v0.3.0
|
60
|
+
|
61
|
+
## Updates
|
25
62
|
|
26
63
|
- Drops Rack Session Access internal require;
|
27
64
|
- Makes `chromedriver-helper` optional.
|
28
65
|
|
29
|
-
|
66
|
+
# v0.2.1
|
67
|
+
|
68
|
+
## Fixes
|
69
|
+
|
70
|
+
- `chrome_headless` was being registered with wrong name.
|
30
71
|
|
31
|
-
|
32
|
-
- `chrome_headless` was being registered with wrong name.
|
72
|
+
# v0.2.0
|
33
73
|
|
34
|
-
##
|
74
|
+
## Features
|
35
75
|
|
36
|
-
-
|
37
|
-
- Add log feature for Chrome and Chrome Headless.
|
76
|
+
- Add log feature for Chrome and Chrome Headless.
|
38
77
|
|
39
|
-
|
78
|
+
# v0.1.0
|
40
79
|
|
41
|
-
First release.
|
80
|
+
- First release.
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Capybara Box
|
2
2
|
|
3
|
-
[![
|
4
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/1b13dc12b03be63baaed/maintainability)](https://codeclimate.com/github/wbotelhos/capybara-box/maintainability)
|
3
|
+
[![CI](https://github.com/wbotelhos/capybara-box/workflows/CI/badge.svg)](https://github.com/wbotelhos/capybara-box/actions)
|
5
4
|
[![Gem Version](https://badge.fury.io/rb/capybara-box.svg)](https://badge.fury.io/rb/capybara-box)
|
6
|
-
[![
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/f312587b4f126bb13e85/maintainability)](https://codeclimate.com/github/wbotelhos/capybara-box/maintainability)
|
6
|
+
[![Coverage](https://codecov.io/gh/wbotelhos/capybara-box/branch/main/graph/badge.svg)](https://codecov.io/gh/wbotelhos/capybara-box)
|
7
|
+
[![Sponsor](https://img.shields.io/badge/sponsor-%3C3-green)](https://www.patreon.com/wbotelhos)
|
7
8
|
|
8
9
|
Configure Capybara with **Chrome**, **Chrome Headless**, **Firefox** and **Firefox Headless** with *Screenshot* feature without losing your mind.
|
9
10
|
|
@@ -30,6 +31,10 @@ CapybaraBox::Base.configure
|
|
30
31
|
|
31
32
|
By default, `selenium_chrome` is the driver, but you can use `selenium_chrome_headless` and `selenium_firefox` or `selenium_firefox_headless` too.
|
32
33
|
|
34
|
+
```ruby
|
35
|
+
CapybaraBox::Base.configure(browser: :selenium_firefox)
|
36
|
+
```
|
37
|
+
|
33
38
|
## Version
|
34
39
|
|
35
40
|
The version is setted via `webdrivers`. You can specify the version:
|
data/lib/capybara-box/base.rb
CHANGED
@@ -9,17 +9,29 @@ module CapybaraBox
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def add_argument(value)
|
12
|
-
|
12
|
+
capabilities&.add_argument(value)
|
13
13
|
end
|
14
14
|
|
15
15
|
def add_preference(key, value)
|
16
|
-
|
16
|
+
capabilities&.add_preference(key, value)
|
17
17
|
end
|
18
18
|
|
19
19
|
def apply_arguments
|
20
20
|
arguments.each { |argument| add_argument(argument) }
|
21
21
|
|
22
|
-
|
22
|
+
if chrome_headless?
|
23
|
+
add_argument('--headless')
|
24
|
+
add_argument('--no-sandbox')
|
25
|
+
add_argument('--disable-gpu')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def apply_bin_path(path)
|
30
|
+
if firefox?
|
31
|
+
::Selenium::WebDriver::Firefox.path = path
|
32
|
+
|
33
|
+
::Selenium::WebDriver::Firefox.path
|
34
|
+
end
|
23
35
|
end
|
24
36
|
|
25
37
|
def apply_preferences
|
@@ -39,7 +51,9 @@ module CapybaraBox
|
|
39
51
|
return [] unless chrome_family?
|
40
52
|
|
41
53
|
%w[
|
54
|
+
--disable-background-networking
|
42
55
|
--disable-default-apps
|
56
|
+
--disable-dev-shm-usage
|
43
57
|
--disable-extensions
|
44
58
|
--disable-infobars
|
45
59
|
--disable-notifications
|
@@ -49,11 +63,17 @@ module CapybaraBox
|
|
49
63
|
--disable-popup-blocking
|
50
64
|
--disable-save-password-bubble
|
51
65
|
--disable-site-isolation-trials
|
66
|
+
--disable-sync
|
52
67
|
--disable-translate
|
68
|
+
--hide-scrollbars
|
53
69
|
--incognito
|
70
|
+
--metrics-recording-only
|
54
71
|
--mute-audio
|
55
72
|
--no-default-browser-check
|
73
|
+
--no-first-run
|
74
|
+
--safebrowsing-disable-auto-update
|
56
75
|
--start-fullscreen
|
76
|
+
--window-size=1920,1080
|
57
77
|
]
|
58
78
|
end
|
59
79
|
|
@@ -74,20 +94,16 @@ module CapybaraBox
|
|
74
94
|
Capybara.default_max_wait_time = @max_wait_time if @max_wait_time
|
75
95
|
end
|
76
96
|
|
77
|
-
def
|
78
|
-
if
|
79
|
-
::Selenium::WebDriver::Firefox::Binary.path = path
|
80
|
-
|
81
|
-
::Selenium::WebDriver::Firefox::Binary.path
|
82
|
-
end
|
97
|
+
def capabilities
|
98
|
+
@capabilities ||= ::Selenium::WebDriver::Chrome::Options.new if chrome_family?
|
83
99
|
end
|
84
100
|
|
85
101
|
def create
|
86
102
|
apply_arguments
|
87
103
|
apply_preferences
|
88
104
|
|
89
|
-
apply_bin_path(@parameters[:bin_path]) if @parameters[:bin_path]
|
90
|
-
apply_version(@parameters[:version]) if
|
105
|
+
apply_bin_path(@parameters[:bin_path]) if ::CapybaraBox::Helper.present?(@parameters[:bin_path])
|
106
|
+
apply_version(@parameters[:version]) if ::CapybaraBox::Helper.present?(@parameters[:version])
|
91
107
|
|
92
108
|
::CapybaraBox::Screenshot.configure(@parameters[:screenshot], @browser) if @parameters[:screenshot]
|
93
109
|
|
@@ -97,8 +113,8 @@ module CapybaraBox
|
|
97
113
|
end
|
98
114
|
|
99
115
|
def driver(app)
|
100
|
-
opts
|
101
|
-
opts[:
|
116
|
+
opts = {}
|
117
|
+
opts[:capabilities] = capabilities if chrome_family?
|
102
118
|
|
103
119
|
Capybara::Selenium::Driver.load_selenium
|
104
120
|
|
@@ -142,10 +158,6 @@ module CapybaraBox
|
|
142
158
|
@http_client ||= ::Selenium::WebDriver::Remote::Http::Default.new(**http_client_options)
|
143
159
|
end
|
144
160
|
|
145
|
-
def options
|
146
|
-
@options ||= ::Selenium::WebDriver::Chrome::Options.new if chrome_family?
|
147
|
-
end
|
148
|
-
|
149
161
|
def preferences
|
150
162
|
return @parameters[:preferences] if @parameters[:preferences]
|
151
163
|
return {} unless chrome_family?
|
@@ -163,7 +175,7 @@ module CapybaraBox
|
|
163
175
|
Capybara.register_driver(name.to_sym) { |app| driver(app) }
|
164
176
|
end
|
165
177
|
|
166
|
-
def self.configure(parameters)
|
178
|
+
def self.configure(parameters = {})
|
167
179
|
new(parameters).tap(&:create)
|
168
180
|
end
|
169
181
|
|
data/lib/capybara-box/helper.rb
CHANGED
@@ -17,11 +17,11 @@ module CapybaraBox
|
|
17
17
|
example.full_description.downcase.gsub('#', '--').tr ' ', '-'
|
18
18
|
end
|
19
19
|
|
20
|
-
if options[:s3]
|
20
|
+
if ::CapybaraBox::Helper.true?(options[:s3])
|
21
21
|
bucket_name = ENV['CAPYBARA_BOX__S3_BUCKET_NAME']
|
22
22
|
region = ENV['CAPYBARA_BOX__S3_REGION']
|
23
23
|
|
24
|
-
|
24
|
+
s3_configuration = {
|
25
25
|
bucket_name: bucket_name,
|
26
26
|
bucket_host: "#{bucket_name}.#{region}.amazonaws.com",
|
27
27
|
|
@@ -31,8 +31,12 @@ module CapybaraBox
|
|
31
31
|
secret_access_key: ENV['CAPYBARA_BOX__S3_SECRET_ACCESS_KEY']
|
32
32
|
},
|
33
33
|
}
|
34
|
+
else
|
35
|
+
s3_configuration = {}
|
34
36
|
end
|
35
37
|
|
38
|
+
Capybara::Screenshot.s3_configuration = s3_configuration
|
39
|
+
|
36
40
|
Capybara::Screenshot.register_driver(browser_name) do |driver, path|
|
37
41
|
driver.browser.save_screenshot(path)
|
38
42
|
end
|
data/lib/capybara-box/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Washington Botelho
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara-screenshot
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: codecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: pry-byebug
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,7 +171,7 @@ homepage: https://github.com/wbotelhos/capybara-box
|
|
157
171
|
licenses:
|
158
172
|
- MIT
|
159
173
|
metadata: {}
|
160
|
-
post_install_message:
|
174
|
+
post_install_message:
|
161
175
|
rdoc_options: []
|
162
176
|
require_paths:
|
163
177
|
- lib
|
@@ -172,8 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
186
|
- !ruby/object:Gem::Version
|
173
187
|
version: '0'
|
174
188
|
requirements: []
|
175
|
-
rubygems_version: 3.
|
176
|
-
signing_key:
|
189
|
+
rubygems_version: 3.2.22
|
190
|
+
signing_key:
|
177
191
|
specification_version: 4
|
178
192
|
summary: A Tool Box for Capybara.
|
179
193
|
test_files: []
|