capybara-headless_chrome 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/capybara/headless_chrome/driver.rb +29 -16
- data/lib/capybara/headless_chrome/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4432726eb0077966a927e83294832698bd4a83af
|
4
|
+
data.tar.gz: b88fa077f4059de93dfd7368e6831a914222a4dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd122aa705502ecd41c7ba1905a29e845e1e6648eb4128df1ecc6c619e81a6c2bd9d10201f46d4a8e435b902159f05ec3d6e017c5256bb2400cd0d73825b10c
|
7
|
+
data.tar.gz: d35e79b7b6ab343b967cbbb76020b85b3c538ee2cdca8fa609b59332ac900720ed3e5c6c52f29df105465a8b71f04ae705f4eb1a652a668bbe8078ca12405f23
|
@@ -6,8 +6,8 @@ require "capybara/headless_chrome/downloads"
|
|
6
6
|
module Capybara
|
7
7
|
module HeadlessChrome
|
8
8
|
class Driver < Capybara::Selenium::Driver
|
9
|
-
def initialize app,
|
10
|
-
super
|
9
|
+
def initialize app, options={}
|
10
|
+
super app, browser: :chrome, desired_capabilities: chrome_capabilities(options)
|
11
11
|
configure_downloads
|
12
12
|
fix_whitespace
|
13
13
|
end
|
@@ -34,32 +34,45 @@ module Capybara
|
|
34
34
|
.to_a
|
35
35
|
end
|
36
36
|
|
37
|
-
def chrome_capabilities
|
37
|
+
def chrome_capabilities options
|
38
38
|
::Selenium::WebDriver::Remote::Capabilities.chrome(
|
39
39
|
chromeOptions: {
|
40
|
-
args:
|
41
|
-
prefs: chrome_preferences
|
40
|
+
args: options_to_arguments(default_chrome_arguments.merge(options)),
|
41
|
+
prefs: chrome_preferences,
|
42
42
|
}
|
43
43
|
)
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
def options_to_arguments options
|
47
|
+
options.map do |key, value|
|
48
|
+
arg = key.to_s.gsub(/_/,'-')
|
49
|
+
if [true, false].include?(value)
|
50
|
+
arg if value
|
51
|
+
elsif value.is_a?(Array)
|
52
|
+
"#{arg}=#{value.join(",")}"
|
53
|
+
else
|
54
|
+
raise NotImplementedError.new(message: [key, value])
|
55
|
+
end
|
56
|
+
end.compact
|
57
|
+
end
|
58
|
+
|
59
|
+
def default_chrome_arguments
|
60
|
+
{
|
61
|
+
no_sandbox: true,
|
62
|
+
headless: true,
|
63
|
+
disable_infobars: true,
|
64
|
+
disable_popup_blocking: true,
|
65
|
+
disable_gpu: true,
|
66
|
+
window_size: [1280,1024],
|
67
|
+
}
|
55
68
|
end
|
56
69
|
|
57
70
|
def chrome_preferences
|
58
71
|
{
|
59
|
-
"download.default_directory"
|
72
|
+
"download.default_directory": downloads.dir,
|
60
73
|
"download.directory_upgrade": "true",
|
61
74
|
"download.prompt_for_download": "false",
|
62
|
-
"browser.set_download_behavior": "{ behavior: 'allow' }",
|
75
|
+
"browser.set_download_behavior": "{ 'behavior': 'allow' }",
|
63
76
|
}
|
64
77
|
end
|
65
78
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-headless_chrome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chromedriver-helper
|