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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef4f12c23030bdb00d8c24f495d8ebe76689b2ff
4
- data.tar.gz: fc54211a643936f225f6a7a50c16bf37d99b0074
3
+ metadata.gz: 4432726eb0077966a927e83294832698bd4a83af
4
+ data.tar.gz: b88fa077f4059de93dfd7368e6831a914222a4dd
5
5
  SHA512:
6
- metadata.gz: af7ac8e05e5a984067441fd4ff969a3ac2fd38ae2c305e63a6bfe44be3fae681b88191d099f8591d9214f61e14f1f7d7a91d073f8836732fe6c784743214a075
7
- data.tar.gz: 41691d7b8f3d1f006c03a7de7bebb3b9a61f3ff3c21e3797e275f4b40f537f8aa4a982b579f9400a7e5d4097e0f3a67400929172c588c7106307afe22c8db741
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, args: []
10
- super(app, browser: :chrome, desired_capabilities: chrome_capabilities(args))
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 args
37
+ def chrome_capabilities options
38
38
  ::Selenium::WebDriver::Remote::Capabilities.chrome(
39
39
  chromeOptions: {
40
- args: chrome_arguments + 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 chrome_arguments
47
- [
48
- "no-sandbox",
49
- "headless",
50
- "disable-infobars",
51
- "disable-popup-blocking",
52
- "disable-gpu",
53
- "window-size=1280,1024",
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" => downloads.dir,
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
 
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module HeadlessChrome
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
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.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-08-30 00:00:00.000000000 Z
11
+ date: 2018-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chromedriver-helper