selenium-webdriver 2.53.4 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/CHANGES +24 -18
  2. data/README.md +2 -3
  3. data/lib/selenium/server.rb +64 -68
  4. data/lib/selenium/webdriver.rb +5 -9
  5. data/lib/selenium/webdriver/chrome.rb +18 -3
  6. data/lib/selenium/webdriver/chrome/bridge.rb +13 -16
  7. data/lib/selenium/webdriver/chrome/profile.rb +7 -9
  8. data/lib/selenium/webdriver/chrome/service.rb +8 -84
  9. data/lib/selenium/webdriver/common.rb +1 -2
  10. data/lib/selenium/webdriver/common/action_builder.rb +28 -38
  11. data/lib/selenium/webdriver/common/alert.rb +7 -10
  12. data/lib/selenium/webdriver/common/bridge_helper.rb +10 -15
  13. data/lib/selenium/webdriver/common/driver.rb +19 -28
  14. data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -3
  15. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +4 -6
  16. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +4 -5
  17. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +0 -2
  18. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +0 -2
  19. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +0 -2
  20. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +0 -3
  21. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +3 -6
  22. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -5
  23. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +2 -5
  24. data/lib/selenium/webdriver/common/element.rb +27 -29
  25. data/lib/selenium/webdriver/common/error.rb +17 -20
  26. data/lib/selenium/webdriver/common/file_reaper.rb +3 -9
  27. data/lib/selenium/webdriver/common/html5/local_storage.rb +6 -8
  28. data/lib/selenium/webdriver/common/html5/session_storage.rb +6 -8
  29. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +6 -15
  30. data/lib/selenium/webdriver/common/keyboard.rb +7 -12
  31. data/lib/selenium/webdriver/common/keys.rb +67 -69
  32. data/lib/selenium/webdriver/common/log_entry.rb +3 -4
  33. data/lib/selenium/webdriver/common/logs.rb +2 -4
  34. data/lib/selenium/webdriver/common/mouse.rb +9 -12
  35. data/lib/selenium/webdriver/common/navigation.rb +2 -4
  36. data/lib/selenium/webdriver/common/options.rb +16 -19
  37. data/lib/selenium/webdriver/common/platform.rb +61 -90
  38. data/lib/selenium/webdriver/common/port_prober.rb +1 -2
  39. data/lib/selenium/webdriver/common/profile_helper.rb +5 -8
  40. data/lib/selenium/webdriver/common/proxy.rb +58 -70
  41. data/lib/selenium/webdriver/common/search_context.rb +15 -19
  42. data/lib/selenium/webdriver/common/service.rb +127 -0
  43. data/lib/selenium/webdriver/common/socket_lock.rb +5 -11
  44. data/lib/selenium/webdriver/common/socket_poller.rb +4 -9
  45. data/lib/selenium/webdriver/common/target_locator.rb +11 -13
  46. data/lib/selenium/webdriver/common/timeouts.rb +4 -6
  47. data/lib/selenium/webdriver/common/touch_action_builder.rb +2 -4
  48. data/lib/selenium/webdriver/common/touch_screen.rb +15 -18
  49. data/lib/selenium/webdriver/common/w3c_error.rb +3 -6
  50. data/lib/selenium/webdriver/common/wait.rb +6 -11
  51. data/lib/selenium/webdriver/common/window.rb +12 -15
  52. data/lib/selenium/webdriver/common/zipper.rb +6 -8
  53. data/lib/selenium/webdriver/edge.rb +18 -3
  54. data/lib/selenium/webdriver/edge/bridge.rb +11 -16
  55. data/lib/selenium/webdriver/edge/legacy_support.rb +38 -39
  56. data/lib/selenium/webdriver/edge/service.rb +8 -82
  57. data/lib/selenium/webdriver/firefox.rb +25 -6
  58. data/lib/selenium/webdriver/firefox/binary.rb +37 -53
  59. data/lib/selenium/webdriver/firefox/bridge.rb +3 -6
  60. data/lib/selenium/webdriver/firefox/extension.rb +4 -6
  61. data/lib/selenium/webdriver/firefox/extension/prefs.json +1 -10
  62. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  63. data/lib/selenium/webdriver/firefox/launcher.rb +8 -11
  64. data/lib/selenium/webdriver/firefox/profile.rb +40 -42
  65. data/lib/selenium/webdriver/firefox/profiles_ini.rb +8 -15
  66. data/lib/selenium/webdriver/firefox/service.rb +23 -79
  67. data/lib/selenium/webdriver/firefox/util.rb +0 -2
  68. data/lib/selenium/webdriver/firefox/w3c_bridge.rb +2 -4
  69. data/lib/selenium/webdriver/ie.rb +16 -7
  70. data/lib/selenium/webdriver/ie/bridge.rb +16 -23
  71. data/lib/selenium/webdriver/{iphone.rb → ie/service.rb} +26 -4
  72. data/lib/selenium/webdriver/phantomjs.rb +8 -3
  73. data/lib/selenium/webdriver/phantomjs/bridge.rb +9 -11
  74. data/lib/selenium/webdriver/phantomjs/service.rb +17 -81
  75. data/lib/selenium/webdriver/remote.rb +0 -2
  76. data/lib/selenium/webdriver/remote/bridge.rb +193 -191
  77. data/lib/selenium/webdriver/remote/capabilities.rb +60 -90
  78. data/lib/selenium/webdriver/remote/commands.rb +197 -192
  79. data/lib/selenium/webdriver/remote/http/common.rb +15 -13
  80. data/lib/selenium/webdriver/remote/http/curb.rb +5 -9
  81. data/lib/selenium/webdriver/remote/http/default.rb +32 -37
  82. data/lib/selenium/webdriver/remote/http/persistent.rb +4 -6
  83. data/lib/selenium/webdriver/remote/response.rb +13 -21
  84. data/lib/selenium/webdriver/remote/server_error.rb +1 -3
  85. data/lib/selenium/webdriver/remote/w3c_bridge.rb +200 -195
  86. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +38 -46
  87. data/lib/selenium/webdriver/remote/w3c_commands.rb +116 -113
  88. data/lib/selenium/webdriver/safari.rb +23 -7
  89. data/lib/selenium/{client/javascript_frameworks/jquery.rb → webdriver/safari/apple_bridge.rb} +28 -9
  90. data/lib/selenium/webdriver/safari/browser.rb +0 -2
  91. data/lib/selenium/webdriver/safari/{bridge.rb → legacy_bridge.rb} +12 -9
  92. data/lib/selenium/webdriver/safari/options.rb +3 -4
  93. data/lib/selenium/webdriver/safari/resources/client.js +56 -7255
  94. data/lib/selenium/webdriver/safari/server.rb +18 -24
  95. data/lib/selenium/{client/javascript_frameworks/prototype.rb → webdriver/safari/service.rb} +27 -9
  96. data/lib/selenium/webdriver/support.rb +1 -0
  97. data/lib/selenium/webdriver/support/abstract_event_listener.rb +17 -2
  98. data/lib/selenium/webdriver/support/block_event_listener.rb +1 -3
  99. data/lib/selenium/webdriver/support/color.rb +55 -38
  100. data/lib/selenium/webdriver/{android.rb → support/escaper.rb} +19 -4
  101. data/lib/selenium/webdriver/support/event_firing_bridge.rb +36 -38
  102. data/lib/selenium/webdriver/support/select.rb +33 -84
  103. data/selenium-webdriver.gemspec +23 -23
  104. metadata +19 -30
  105. data/lib/selenium-client.rb +0 -21
  106. data/lib/selenium/client.rb +0 -57
  107. data/lib/selenium/client/base.rb +0 -151
  108. data/lib/selenium/client/driver.rb +0 -29
  109. data/lib/selenium/client/errors.rb +0 -28
  110. data/lib/selenium/client/extensions.rb +0 -132
  111. data/lib/selenium/client/idiomatic.rb +0 -507
  112. data/lib/selenium/client/javascript_expression_builder.rb +0 -135
  113. data/lib/selenium/client/legacy_driver.rb +0 -1722
  114. data/lib/selenium/client/protocol.rb +0 -123
  115. data/lib/selenium/client/selenium_helper.rb +0 -49
  116. data/lib/selenium/rake/server_task.rb +0 -176
  117. data/lib/selenium/webdriver/android/bridge.rb +0 -68
  118. data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
  119. data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
  120. data/lib/selenium/webdriver/common/html5/location.rb +0 -19
  121. data/lib/selenium/webdriver/ie/server.rb +0 -133
  122. data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
data/CHANGES CHANGED
@@ -1,34 +1,40 @@
1
- 2.53.4 (2016-06-14)
1
+ 3.0.0.beta1 (2016-07-28)
2
2
  ===================
3
3
 
4
- Firefox:
5
- * FirefoxDriver works with v47.0.1 (issue 2110)
4
+ Ruby:
5
+ * Remove support for RC client
6
+ * Remove support for Ruby < 2.0
7
+ * Update code to support designated style guidelines
8
+ * Chrome/GeckoDriver/PhantomJS/IE/Edge drivers are refactored to use standard
9
+ service class (issue 1797)
10
+ * Option `:timeout` was removed from IE server (issue 1797)
6
11
 
7
- 2.53.3 (2016-06-14)
8
- ===================
12
+ Chrome:
13
+ * Remove override of default chromedriver behavior for chrome.detach (issue 2418)
9
14
 
10
15
  Firefox:
11
- * Fix bug with Firefox Binary & Marionette on Remote machines (issue 2281)
16
+ * Rename wires to geckodriver
17
+ * Change default usage from FirefoxDriver to geckodriver
12
18
 
13
- 2.53.2 (2016-06-13)
14
- ===================
15
-
16
- Ruby:
17
- * Fix bug for finding binaries on Windows (issue 2271 & 2273)
18
-
19
- 2.53.1 (2016-06-09)
20
- ===================
19
+ Safari:
20
+ * Initial support for Apple's Safari Driver in Sierra (issue #2475)
21
21
 
22
- Firefox:
23
- * Support for latest geckodriver (formerly wires)
24
- * Escape selector when converting to CSS (issue 2235)
22
+ Android and iPhone:
23
+ * Remove support for deprecated classes (Issue #2476)
25
24
 
26
- 2.53.0 (2016-03-16)
25
+ 2.53.0 (2016-03-15)
27
26
  ===================
28
27
 
29
28
  Ruby:
30
29
  * Removed dependency on "multi_json" (issue 1632)
31
30
  * Properly handle namespaces in install manifest of Firefox add-ons (issue 1143)
31
+ * Improve error handling when stopping browsers (thanks bsedat)
32
+ * Fix deselecting options in select lists (thanks glib-briia)
33
+ * Fix w3c error handling
34
+ * Update w3c Capabilities support
35
+
36
+ IE:
37
+ * support for alert credentials (issue #1698, thanks Alan Baird & trabulmonkee)
32
38
 
33
39
  2.52.0 (2016-02-12)
34
40
  ===================
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # selenium-webdriver
2
2
 
3
3
  This gem provides Ruby bindings for WebDriver
4
- and has been tested to work on MRI (1.9.2 through 2.1),
5
- JRuby and Rubinius.
4
+ and has been tested to work on MRI (2.0 through 2.2),
6
5
 
7
6
  ## Install
8
7
 
@@ -17,7 +16,7 @@ JRuby and Rubinius.
17
16
 
18
17
  ## License
19
18
 
20
- Copyright 2009-2015 Software Freedom Conservancy
19
+ Copyright 2009-2016 Software Freedom Conservancy
21
20
 
22
21
  Licensed to the Software Freedom Conservancy (SFC) under one
23
22
  or more contributor license agreements. See the NOTICE file
@@ -22,7 +22,6 @@ require 'selenium/webdriver/common/socket_poller'
22
22
  require 'net/http'
23
23
 
24
24
  module Selenium
25
-
26
25
  #
27
26
  # Wraps the remote server jar
28
27
  #
@@ -66,59 +65,72 @@ module Selenium
66
65
  # Download the given version of the selenium-server-standalone jar.
67
66
  #
68
67
 
69
- def self.download(required_version)
70
- required_version = latest if required_version == :latest
71
- download_file_name = "selenium-server-standalone-#{required_version}.jar"
68
+ class << self
69
+ def download(required_version)
70
+ required_version = latest if required_version == :latest
71
+ download_file_name = "selenium-server-standalone-#{required_version}.jar"
72
72
 
73
- if File.exists? download_file_name
74
- return download_file_name
75
- end
73
+ return download_file_name if File.exist? download_file_name
76
74
 
77
- begin
78
- open(download_file_name, "wb") do |destination|
79
- net_http.start("selenium-release.storage.googleapis.com") do |http|
80
- resp = http.request_get("/#{required_version[/(\d+\.\d+)\./, 1]}/#{download_file_name}") do |response|
81
- total = response.content_length
82
- progress = 0
83
- segment_count = 0
84
-
85
- response.read_body do |segment|
86
- progress += segment.length
87
- segment_count += 1
88
-
89
- if segment_count % 15 == 0
90
- percent = (progress.to_f / total.to_f) * 100
91
- print "#{CL_RESET}Downloading #{download_file_name}: #{percent.to_i}% (#{progress} / #{total})"
92
- segment_count = 0
93
- end
75
+ begin
76
+ open(download_file_name, 'wb') do |destination|
77
+ net_http.start('selenium-release.storage.googleapis.com') do |http|
78
+ resp = http.request_get("/#{required_version[/(\d+\.\d+)\./, 1]}/#{download_file_name}") do |response|
79
+ total = response.content_length
80
+ progress = 0
81
+ segment_count = 0
94
82
 
95
- destination.write(segment)
83
+ response.read_body do |segment|
84
+ progress += segment.length
85
+ segment_count += 1
86
+
87
+ if segment_count % 15 == 0
88
+ percent = (progress.to_f / total.to_f) * 100
89
+ print "#{CL_RESET}Downloading #{download_file_name}: #{percent.to_i}% (#{progress} / #{total})"
90
+ segment_count = 0
91
+ end
92
+
93
+ destination.write(segment)
94
+ end
96
95
  end
97
- end
98
96
 
99
- unless resp.kind_of? Net::HTTPSuccess
100
- raise Error, "#{resp.code} for #{download_file_name}"
97
+ unless resp.is_a? Net::HTTPSuccess
98
+ raise Error, "#{resp.code} for #{download_file_name}"
99
+ end
101
100
  end
102
101
  end
102
+ rescue
103
+ FileUtils.rm download_file_name if File.exist? download_file_name
104
+ raise
103
105
  end
104
- rescue
105
- FileUtils.rm download_file_name if File.exists? download_file_name
106
- raise
106
+
107
+ download_file_name
107
108
  end
108
109
 
109
- download_file_name
110
- end
110
+ #
111
+ # Ask Google Code what the latest selenium-server-standalone version is.
112
+ #
111
113
 
112
- #
113
- # Ask Google Code what the latest selenium-server-standalone version is.
114
- #
114
+ def latest
115
+ require 'rexml/document'
116
+ net_http.start('selenium-release.storage.googleapis.com') do |http|
117
+ REXML::Document.new(http.get('/').body).root.get_elements('//Contents/Key').map do |e|
118
+ e.text[/selenium-server-standalone-(\d+\.\d+\.\d+)\.jar/, 1]
119
+ end.compact.max
120
+ end
121
+ end
122
+
123
+ def net_http
124
+ http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
115
125
 
116
- def self.latest
117
- require 'rexml/document'
118
- net_http.start("selenium-release.storage.googleapis.com") do |http|
119
- REXML::Document.new(http.get("/").body).root.get_elements("//Contents/Key").map { |e|
120
- e.text[/selenium-server-standalone-(\d+\.\d+\.\d+)\.jar/, 1]
121
- }.compact.max
126
+ if http_proxy
127
+ http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?('http://')
128
+ uri = URI.parse(http_proxy)
129
+
130
+ Net::HTTP::Proxy(uri.host, uri.port)
131
+ else
132
+ Net::HTTP
133
+ end
122
134
  end
123
135
  end
124
136
 
@@ -162,7 +174,7 @@ module Selenium
162
174
  raise Errno::ENOENT, jar unless File.exist?(jar)
163
175
 
164
176
  @jar = jar
165
- @host = "127.0.0.1"
177
+ @host = '127.0.0.1'
166
178
  @port = opts.fetch(:port, 4444)
167
179
  @timeout = opts.fetch(:timeout, 30)
168
180
  @background = opts.fetch(:background, false)
@@ -180,7 +192,7 @@ module Selenium
180
192
 
181
193
  def stop
182
194
  begin
183
- Net::HTTP.get(@host, "/selenium-server/driver/?cmd=shutDownSeleniumServer", @port)
195
+ Net::HTTP.get(@host, '/selenium-server/driver/?cmd=shutDownSeleniumServer', @port)
184
196
  rescue Errno::ECONNREFUSED
185
197
  end
186
198
 
@@ -195,7 +207,7 @@ module Selenium
195
207
  end
196
208
 
197
209
  def <<(arg)
198
- if arg.kind_of?(Array)
210
+ if arg.is_a?(Array)
199
211
  @additional_args += arg
200
212
  else
201
213
  @additional_args << arg.to_s
@@ -204,19 +216,6 @@ module Selenium
204
216
 
205
217
  private
206
218
 
207
- def self.net_http
208
- http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
209
-
210
- if http_proxy
211
- http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?("http://")
212
- uri = URI.parse(http_proxy)
213
-
214
- Net::HTTP::Proxy(uri.host, uri.port)
215
- else
216
- Net::HTTP
217
- end
218
- end
219
-
220
219
  def stop_process
221
220
  return unless @process.alive?
222
221
 
@@ -233,11 +232,11 @@ module Selenium
233
232
 
234
233
  def process
235
234
  @process ||= (
236
- cp = ChildProcess.build("java", "-jar", @jar, "-port", @port.to_s, *@additional_args)
235
+ cp = ChildProcess.build('java', '-jar', @jar, '-port', @port.to_s, *@additional_args)
237
236
  io = cp.io
238
237
 
239
- if @log.kind_of?(String)
240
- @log_file = File.open(@log, "w")
238
+ if @log.is_a?(String)
239
+ @log_file = File.open(@log, 'w')
241
240
  io.stdout = io.stderr = @log_file
242
241
  elsif @log
243
242
  io.inherit!
@@ -250,20 +249,17 @@ module Selenium
250
249
  end
251
250
 
252
251
  def poll_for_service
253
- unless socket.connected?
254
- raise Error, "remote server not launched in #{@timeout} seconds"
255
- end
252
+ return if socket.connected?
253
+ raise Error, "remote server not launched in #{@timeout} seconds"
256
254
  end
257
255
 
258
256
  def poll_for_shutdown
259
- unless socket.closed?
260
- raise Error, "remote server not stopped in #{@timeout} seconds"
261
- end
257
+ return if socket.closed?
258
+ raise Error, "remote server not stopped in #{@timeout} seconds"
262
259
  end
263
260
 
264
261
  def socket
265
262
  @socket ||= WebDriver::SocketPoller.new(@host, @port, @timeout)
266
263
  end
267
-
268
264
  end # Server
269
265
  end # Selenium
@@ -31,12 +31,10 @@ module Selenium
31
31
  Dimension = Struct.new(:width, :height)
32
32
  Location = Struct.new(:latitude, :longitude, :altitude)
33
33
 
34
- autoload :Android, 'selenium/webdriver/android'
35
34
  autoload :Chrome, 'selenium/webdriver/chrome'
36
35
  autoload :Edge, 'selenium/webdriver/edge'
37
36
  autoload :Firefox, 'selenium/webdriver/firefox'
38
37
  autoload :IE, 'selenium/webdriver/ie'
39
- autoload :IPhone, 'selenium/webdriver/iphone'
40
38
  autoload :PhantomJS, 'selenium/webdriver/phantomjs'
41
39
  autoload :Remote, 'selenium/webdriver/remote'
42
40
  autoload :Safari, 'selenium/webdriver/safari'
@@ -45,13 +43,13 @@ module Selenium
45
43
  # @api private
46
44
 
47
45
  def self.root
48
- @root ||= File.expand_path("../..", __FILE__)
46
+ @root ||= File.expand_path('../..', __FILE__)
49
47
  end
50
48
 
51
49
  #
52
50
  # Create a new Driver instance with the correct bridge for the given browser
53
51
  #
54
- # @param browser [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :android, :iphone, :phantomjs, :safari]
52
+ # @param browser [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :phantomjs, :safari]
55
53
  # the driver type to use
56
54
  # @param *rest
57
55
  # arguments passed to Bridge.new
@@ -63,8 +61,6 @@ module Selenium
63
61
  # @see Selenium::WebDriver::IE::Bridge
64
62
  # @see Selenium::WebDriver::Edge::Bridge
65
63
  # @see Selenium::WebDriver::Chrome::Bridge
66
- # @see Selenium::WebDriver::Android::Bridge
67
- # @see Selenium::WebDriver::IPhone::Bridge
68
64
  # @see Selenium::WebDriver::PhantomJS::Bridge
69
65
  # @see Selenium::WebDriver::Safari::Bridge
70
66
  #
@@ -74,8 +70,9 @@ module Selenium
74
70
  # WebDriver.for :firefox, :profile => Profile.new
75
71
  # WebDriver.for :remote, :url => "http://localhost:4444/wd/hub", :desired_capabilities => caps
76
72
  #
77
- # One special argument is not passed on to the bridges, :listener. You can pass a listener for this option
78
- # to get notified of WebDriver events. The passed object must respond to #call or implement the methods from AbstractEventListener.
73
+ # One special argument is not passed on to the bridges, :listener.
74
+ # You can pass a listener for this option to get notified of WebDriver events.
75
+ # The passed object must respond to #call or implement the methods from AbstractEventListener.
79
76
  #
80
77
  # @see Selenium::WebDriver::Support::AbstractEventListener
81
78
  #
@@ -83,6 +80,5 @@ module Selenium
83
80
  def self.for(*args)
84
81
  WebDriver::Driver.for(*args)
85
82
  end
86
-
87
83
  end # WebDriver
88
84
  end # Selenium
@@ -25,10 +25,26 @@ require 'selenium/webdriver/chrome/profile'
25
25
 
26
26
  module Selenium
27
27
  module WebDriver
28
-
29
28
  module Chrome
29
+ MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
30
+ Unable to find chromedriver. Please download the server from
31
+ http://chromedriver.storage.googleapis.com/index.html and place it
32
+ somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.
33
+ ERROR
34
+
30
35
  def self.driver_path=(path)
31
- Service.executable_path = path
36
+ Platform.assert_executable path
37
+ @driver_path = path
38
+ end
39
+
40
+ def self.driver_path
41
+ @driver_path ||= begin
42
+ path = Platform.find_binary('chromedriver')
43
+ raise Error::WebDriverError, MISSING_TEXT unless path
44
+ Platform.assert_executable path
45
+
46
+ path
47
+ end
32
48
  end
33
49
 
34
50
  def self.path=(path)
@@ -39,7 +55,6 @@ module Selenium
39
55
  def self.path
40
56
  @path ||= nil
41
57
  end
42
-
43
58
  end # Chrome
44
59
  end # WebDriver
45
60
  end # Selenium
@@ -20,17 +20,15 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Chrome
23
-
24
23
  # @api private
25
24
  class Bridge < Remote::Bridge
26
-
27
25
  def initialize(opts = {})
28
26
  http_client = opts.delete(:http_client)
29
27
 
30
- if opts.has_key?(:url)
28
+ if opts.key?(:url)
31
29
  url = opts.delete(:url)
32
30
  else
33
- @service = Service.default_service(*extract_service_args(opts))
31
+ @service = Service.new(Chrome.driver_path, Service::DEFAULT_PORT, *extract_service_args(opts))
34
32
  @service.start
35
33
 
36
34
  url = @service.uri
@@ -39,11 +37,11 @@ module Selenium
39
37
  caps = create_capabilities(opts)
40
38
 
41
39
  remote_opts = {
42
- :url => url,
43
- :desired_capabilities => caps
40
+ url: url,
41
+ desired_capabilities: caps
44
42
  }
45
43
 
46
- remote_opts.merge!(:http_client => http_client) if http_client
44
+ remote_opts[:http_client] = http_client if http_client
47
45
 
48
46
  super(remote_opts)
49
47
  end
@@ -90,24 +88,24 @@ module Selenium
90
88
  chrome_options = caps['chromeOptions'] || {}
91
89
 
92
90
  if args
93
- unless args.kind_of? Array
94
- raise ArgumentError, ":args must be an Array of Strings"
91
+ unless args.is_a? Array
92
+ raise ArgumentError, ':args must be an Array of Strings'
95
93
  end
96
94
 
97
- chrome_options['args'] = args.map { |e| e.to_s }
95
+ chrome_options['args'] = args.map(&:to_s)
98
96
  end
99
97
 
100
98
  if profile
101
99
  data = profile.as_json
102
100
 
103
- chrome_options.merge! 'profile' => data['zip'],
104
- 'extensions' => data['extensions']
101
+ chrome_options['profile'] = data['zip']
102
+ chrome_options['extensions'] = data['extensions']
105
103
  end
106
104
 
107
105
  chrome_options['binary'] = Chrome.path if Chrome.path
108
106
  chrome_options['nativeEvents'] = true if native_events
109
107
  chrome_options['verbose'] = true if verbose
110
- chrome_options['detach'] = detach.nil? || !!detach
108
+ chrome_options['detach'] = true if detach
111
109
  chrome_options['noWebsiteTestingDefaults'] = true if no_website_testing_defaults
112
110
  chrome_options['prefs'] = prefs if prefs
113
111
 
@@ -115,7 +113,7 @@ module Selenium
115
113
  caps['proxy'] = proxy if proxy
116
114
 
117
115
  # legacy options - for chromedriver < 17.0.963.0
118
- caps["chrome.switches"] = chrome_options['args'] if chrome_options.member?('args')
116
+ caps['chrome.switches'] = chrome_options['args'] if chrome_options.member?('args')
119
117
  %w[binary detach extensions nativeEvents noWebsiteTestingDefaults prefs profile verbose].each do |key|
120
118
  caps["chrome.#{key}"] = chrome_options[key] if chrome_options.member?(key)
121
119
  end
@@ -126,13 +124,12 @@ module Selenium
126
124
  def extract_service_args(opts)
127
125
  args = []
128
126
 
129
- if opts.has_key?(:service_log_path)
127
+ if opts.key?(:service_log_path)
130
128
  args << "--log-path=#{opts.delete(:service_log_path)}"
131
129
  end
132
130
 
133
131
  args
134
132
  end
135
-
136
133
  end # Bridge
137
134
  end # Chrome
138
135
  end # WebDriver