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.
- data/CHANGES +24 -18
- data/README.md +2 -3
- data/lib/selenium/server.rb +64 -68
- data/lib/selenium/webdriver.rb +5 -9
- data/lib/selenium/webdriver/chrome.rb +18 -3
- data/lib/selenium/webdriver/chrome/bridge.rb +13 -16
- data/lib/selenium/webdriver/chrome/profile.rb +7 -9
- data/lib/selenium/webdriver/chrome/service.rb +8 -84
- data/lib/selenium/webdriver/common.rb +1 -2
- data/lib/selenium/webdriver/common/action_builder.rb +28 -38
- data/lib/selenium/webdriver/common/alert.rb +7 -10
- data/lib/selenium/webdriver/common/bridge_helper.rb +10 -15
- data/lib/selenium/webdriver/common/driver.rb +19 -28
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -3
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +4 -6
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +4 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +0 -3
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +3 -6
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -5
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +2 -5
- data/lib/selenium/webdriver/common/element.rb +27 -29
- data/lib/selenium/webdriver/common/error.rb +17 -20
- data/lib/selenium/webdriver/common/file_reaper.rb +3 -9
- data/lib/selenium/webdriver/common/html5/local_storage.rb +6 -8
- data/lib/selenium/webdriver/common/html5/session_storage.rb +6 -8
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +6 -15
- data/lib/selenium/webdriver/common/keyboard.rb +7 -12
- data/lib/selenium/webdriver/common/keys.rb +67 -69
- data/lib/selenium/webdriver/common/log_entry.rb +3 -4
- data/lib/selenium/webdriver/common/logs.rb +2 -4
- data/lib/selenium/webdriver/common/mouse.rb +9 -12
- data/lib/selenium/webdriver/common/navigation.rb +2 -4
- data/lib/selenium/webdriver/common/options.rb +16 -19
- data/lib/selenium/webdriver/common/platform.rb +61 -90
- data/lib/selenium/webdriver/common/port_prober.rb +1 -2
- data/lib/selenium/webdriver/common/profile_helper.rb +5 -8
- data/lib/selenium/webdriver/common/proxy.rb +58 -70
- data/lib/selenium/webdriver/common/search_context.rb +15 -19
- data/lib/selenium/webdriver/common/service.rb +127 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +5 -11
- data/lib/selenium/webdriver/common/socket_poller.rb +4 -9
- data/lib/selenium/webdriver/common/target_locator.rb +11 -13
- data/lib/selenium/webdriver/common/timeouts.rb +4 -6
- data/lib/selenium/webdriver/common/touch_action_builder.rb +2 -4
- data/lib/selenium/webdriver/common/touch_screen.rb +15 -18
- data/lib/selenium/webdriver/common/w3c_error.rb +3 -6
- data/lib/selenium/webdriver/common/wait.rb +6 -11
- data/lib/selenium/webdriver/common/window.rb +12 -15
- data/lib/selenium/webdriver/common/zipper.rb +6 -8
- data/lib/selenium/webdriver/edge.rb +18 -3
- data/lib/selenium/webdriver/edge/bridge.rb +11 -16
- data/lib/selenium/webdriver/edge/legacy_support.rb +38 -39
- data/lib/selenium/webdriver/edge/service.rb +8 -82
- data/lib/selenium/webdriver/firefox.rb +25 -6
- data/lib/selenium/webdriver/firefox/binary.rb +37 -53
- data/lib/selenium/webdriver/firefox/bridge.rb +3 -6
- data/lib/selenium/webdriver/firefox/extension.rb +4 -6
- data/lib/selenium/webdriver/firefox/extension/prefs.json +1 -10
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +8 -11
- data/lib/selenium/webdriver/firefox/profile.rb +40 -42
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +8 -15
- data/lib/selenium/webdriver/firefox/service.rb +23 -79
- data/lib/selenium/webdriver/firefox/util.rb +0 -2
- data/lib/selenium/webdriver/firefox/w3c_bridge.rb +2 -4
- data/lib/selenium/webdriver/ie.rb +16 -7
- data/lib/selenium/webdriver/ie/bridge.rb +16 -23
- data/lib/selenium/webdriver/{iphone.rb → ie/service.rb} +26 -4
- data/lib/selenium/webdriver/phantomjs.rb +8 -3
- data/lib/selenium/webdriver/phantomjs/bridge.rb +9 -11
- data/lib/selenium/webdriver/phantomjs/service.rb +17 -81
- data/lib/selenium/webdriver/remote.rb +0 -2
- data/lib/selenium/webdriver/remote/bridge.rb +193 -191
- data/lib/selenium/webdriver/remote/capabilities.rb +60 -90
- data/lib/selenium/webdriver/remote/commands.rb +197 -192
- data/lib/selenium/webdriver/remote/http/common.rb +15 -13
- data/lib/selenium/webdriver/remote/http/curb.rb +5 -9
- data/lib/selenium/webdriver/remote/http/default.rb +32 -37
- data/lib/selenium/webdriver/remote/http/persistent.rb +4 -6
- data/lib/selenium/webdriver/remote/response.rb +13 -21
- data/lib/selenium/webdriver/remote/server_error.rb +1 -3
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +200 -195
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +38 -46
- data/lib/selenium/webdriver/remote/w3c_commands.rb +116 -113
- data/lib/selenium/webdriver/safari.rb +23 -7
- data/lib/selenium/{client/javascript_frameworks/jquery.rb → webdriver/safari/apple_bridge.rb} +28 -9
- data/lib/selenium/webdriver/safari/browser.rb +0 -2
- data/lib/selenium/webdriver/safari/{bridge.rb → legacy_bridge.rb} +12 -9
- data/lib/selenium/webdriver/safari/options.rb +3 -4
- data/lib/selenium/webdriver/safari/resources/client.js +56 -7255
- data/lib/selenium/webdriver/safari/server.rb +18 -24
- data/lib/selenium/{client/javascript_frameworks/prototype.rb → webdriver/safari/service.rb} +27 -9
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +17 -2
- data/lib/selenium/webdriver/support/block_event_listener.rb +1 -3
- data/lib/selenium/webdriver/support/color.rb +55 -38
- data/lib/selenium/webdriver/{android.rb → support/escaper.rb} +19 -4
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +36 -38
- data/lib/selenium/webdriver/support/select.rb +33 -84
- data/selenium-webdriver.gemspec +23 -23
- metadata +19 -30
- data/lib/selenium-client.rb +0 -21
- data/lib/selenium/client.rb +0 -57
- data/lib/selenium/client/base.rb +0 -151
- data/lib/selenium/client/driver.rb +0 -29
- data/lib/selenium/client/errors.rb +0 -28
- data/lib/selenium/client/extensions.rb +0 -132
- data/lib/selenium/client/idiomatic.rb +0 -507
- data/lib/selenium/client/javascript_expression_builder.rb +0 -135
- data/lib/selenium/client/legacy_driver.rb +0 -1722
- data/lib/selenium/client/protocol.rb +0 -123
- data/lib/selenium/client/selenium_helper.rb +0 -49
- data/lib/selenium/rake/server_task.rb +0 -176
- data/lib/selenium/webdriver/android/bridge.rb +0 -68
- data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
- data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
- data/lib/selenium/webdriver/common/html5/location.rb +0 -19
- data/lib/selenium/webdriver/ie/server.rb +0 -133
- data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
data/CHANGES
CHANGED
@@ -1,34 +1,40 @@
|
|
1
|
-
|
1
|
+
3.0.0.beta1 (2016-07-28)
|
2
2
|
===================
|
3
3
|
|
4
|
-
|
5
|
-
*
|
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
|
-
|
8
|
-
|
12
|
+
Chrome:
|
13
|
+
* Remove override of default chromedriver behavior for chrome.detach (issue 2418)
|
9
14
|
|
10
15
|
Firefox:
|
11
|
-
*
|
16
|
+
* Rename wires to geckodriver
|
17
|
+
* Change default usage from FirefoxDriver to geckodriver
|
12
18
|
|
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
|
-
|
23
|
-
*
|
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-
|
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 (
|
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-
|
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
|
data/lib/selenium/server.rb
CHANGED
@@ -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
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
74
|
-
return download_file_name
|
75
|
-
end
|
73
|
+
return download_file_name if File.exist? download_file_name
|
76
74
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
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
|
-
|
100
|
-
|
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
|
-
|
105
|
-
|
106
|
-
raise
|
106
|
+
|
107
|
+
download_file_name
|
107
108
|
end
|
108
109
|
|
109
|
-
|
110
|
-
|
110
|
+
#
|
111
|
+
# Ask Google Code what the latest selenium-server-standalone version is.
|
112
|
+
#
|
111
113
|
|
112
|
-
|
113
|
-
|
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
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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 =
|
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,
|
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.
|
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(
|
235
|
+
cp = ChildProcess.build('java', '-jar', @jar, '-port', @port.to_s, *@additional_args)
|
237
236
|
io = cp.io
|
238
237
|
|
239
|
-
if @log.
|
240
|
-
@log_file = File.open(@log,
|
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
|
-
|
254
|
-
|
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
|
-
|
260
|
-
|
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
|
data/lib/selenium/webdriver.rb
CHANGED
@@ -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(
|
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, :
|
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.
|
78
|
-
#
|
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
|
-
|
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.
|
28
|
+
if opts.key?(:url)
|
31
29
|
url = opts.delete(:url)
|
32
30
|
else
|
33
|
-
@service = Service.
|
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
|
-
:
|
43
|
-
:
|
40
|
+
url: url,
|
41
|
+
desired_capabilities: caps
|
44
42
|
}
|
45
43
|
|
46
|
-
remote_opts
|
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.
|
94
|
-
raise ArgumentError,
|
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
|
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
|
104
|
-
|
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'] =
|
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[
|
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.
|
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
|