selenium-webdriver 2.53.3 → 3.142.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGES +665 -8
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +2 -3
- data/lib/selenium/server.rb +76 -73
- data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
- data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
- data/lib/selenium/webdriver/{phantomjs.rb → atoms.rb} +10 -14
- data/lib/selenium/webdriver/chrome/bridge.rb +30 -101
- data/lib/selenium/webdriver/chrome/driver.rb +127 -0
- data/lib/selenium/webdriver/chrome/options.rb +190 -0
- data/lib/selenium/webdriver/chrome/profile.rb +21 -20
- data/lib/selenium/webdriver/chrome/service.rb +26 -93
- data/lib/selenium/webdriver/chrome.rb +15 -6
- data/lib/selenium/webdriver/common/action_builder.rb +52 -58
- data/lib/selenium/webdriver/common/alert.rb +7 -15
- data/lib/selenium/webdriver/common/bridge_helper.rb +18 -22
- data/lib/selenium/webdriver/common/driver.rb +72 -72
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_input_devices.rb → has_debugger.rb} +11 -27
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +6 -10
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +7 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +3 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -5
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +6 -9
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -7
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -8
- data/lib/selenium/webdriver/common/element.rb +59 -39
- data/lib/selenium/webdriver/common/error.rb +259 -104
- data/lib/selenium/webdriver/common/file_reaper.rb +6 -14
- data/lib/selenium/webdriver/common/html5/local_storage.rb +8 -10
- data/lib/selenium/webdriver/common/html5/session_storage.rb +8 -10
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +8 -16
- data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
- data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
- data/lib/selenium/webdriver/{safari/browser.rb → common/interactions/interactions.rb} +17 -14
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
- data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
- data/lib/selenium/webdriver/{android.rb → common/interactions/none_input.rb} +14 -6
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
- data/lib/selenium/webdriver/common/keyboard.rb +10 -14
- data/lib/selenium/webdriver/common/keys.rb +102 -82
- data/lib/selenium/webdriver/common/log_entry.rb +7 -8
- data/lib/selenium/webdriver/common/logger.rb +115 -0
- data/lib/selenium/webdriver/common/logs.rb +4 -6
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/mouse.rb +12 -14
- data/lib/selenium/webdriver/common/navigation.rb +4 -6
- data/lib/selenium/webdriver/common/options.rb +26 -127
- data/lib/selenium/webdriver/common/platform.rb +75 -101
- data/lib/selenium/webdriver/common/port_prober.rb +7 -19
- data/lib/selenium/webdriver/common/profile_helper.rb +8 -11
- data/lib/selenium/webdriver/common/proxy.rb +68 -74
- data/lib/selenium/webdriver/common/search_context.rb +28 -37
- data/lib/selenium/webdriver/common/service.rb +219 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +15 -16
- data/lib/selenium/webdriver/common/socket_poller.rb +30 -28
- data/lib/selenium/webdriver/common/target_locator.rb +16 -18
- data/lib/selenium/webdriver/common/timeouts.rb +6 -8
- data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -10
- data/lib/selenium/webdriver/common/touch_screen.rb +22 -23
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +212 -0
- data/lib/selenium/webdriver/common/w3c_manager.rb +45 -0
- data/lib/selenium/webdriver/common/wait.rb +17 -16
- data/lib/selenium/webdriver/common/window.rb +50 -17
- data/lib/selenium/webdriver/common/zipper.rb +9 -13
- data/lib/selenium/webdriver/common.rb +21 -7
- data/lib/selenium/webdriver/edge/bridge.rb +34 -63
- data/lib/selenium/webdriver/edge/driver.rb +66 -0
- data/lib/selenium/webdriver/edge/options.rb +80 -0
- data/lib/selenium/webdriver/edge/service.rb +23 -95
- data/lib/selenium/webdriver/edge.rb +13 -13
- data/lib/selenium/webdriver/firefox/binary.rb +45 -60
- data/lib/selenium/webdriver/firefox/driver.rb +50 -0
- data/lib/selenium/webdriver/firefox/extension/prefs.json +3 -12
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/extension.rb +20 -10
- data/lib/selenium/webdriver/firefox/launcher.rb +16 -22
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +83 -0
- data/lib/selenium/webdriver/firefox/marionette/bridge.rb +49 -0
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +90 -0
- data/lib/selenium/webdriver/firefox/options.rb +162 -0
- data/lib/selenium/webdriver/firefox/profile.rb +47 -48
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +11 -18
- data/lib/selenium/webdriver/firefox/service.rb +24 -95
- data/lib/selenium/webdriver/firefox/util.rb +2 -4
- data/lib/selenium/webdriver/firefox.rb +27 -12
- data/lib/selenium/webdriver/ie/driver.rb +85 -0
- data/lib/selenium/webdriver/ie/options.rb +138 -0
- data/lib/selenium/webdriver/ie/service.rb +54 -0
- data/lib/selenium/webdriver/ie.rb +12 -10
- data/lib/selenium/webdriver/remote/bridge.rb +100 -564
- data/lib/selenium/webdriver/remote/capabilities.rb +98 -100
- data/lib/selenium/webdriver/remote/driver.rb +51 -0
- data/lib/selenium/webdriver/remote/http/common.rb +34 -22
- data/lib/selenium/webdriver/remote/http/curb.rb +13 -14
- data/lib/selenium/webdriver/remote/http/default.rb +62 -43
- data/lib/selenium/webdriver/remote/http/persistent.rb +12 -9
- data/lib/selenium/webdriver/remote/oss/bridge.rb +594 -0
- data/lib/selenium/webdriver/remote/oss/commands.rb +223 -0
- data/lib/selenium/webdriver/remote/response.rb +48 -28
- data/lib/selenium/webdriver/remote/server_error.rb +3 -5
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +605 -0
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +310 -0
- data/lib/selenium/webdriver/remote/w3c/commands.rb +157 -0
- data/lib/selenium/webdriver/remote.rb +10 -16
- data/lib/selenium/webdriver/safari/bridge.rb +17 -101
- data/lib/selenium/webdriver/{firefox/w3c_bridge.rb → safari/driver.rb} +27 -25
- data/lib/selenium/webdriver/safari/options.rb +29 -31
- data/lib/selenium/webdriver/safari/service.rb +38 -0
- data/lib/selenium/webdriver/safari.rb +27 -27
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +19 -4
- data/lib/selenium/webdriver/support/block_event_listener.rb +3 -5
- data/lib/selenium/webdriver/support/color.rb +60 -43
- data/lib/selenium/webdriver/support/escaper.rb +43 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +39 -41
- data/lib/selenium/webdriver/support/select.rb +45 -97
- data/lib/selenium/webdriver/support.rb +3 -2
- data/lib/selenium/webdriver/{iphone.rb → version.rb} +3 -7
- data/lib/selenium/webdriver.rb +36 -23
- data/lib/selenium-webdriver.rb +2 -2
- data/selenium-webdriver.gemspec +42 -29
- metadata +331 -262
- 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/javascript_frameworks/jquery.rb +0 -32
- data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -32
- 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/client.rb +0 -57
- 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/common/w3c_error.rb +0 -194
- data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
- data/lib/selenium/webdriver/firefox/bridge.rb +0 -89
- data/lib/selenium/webdriver/ie/bridge.rb +0 -88
- data/lib/selenium/webdriver/ie/server.rb +0 -133
- data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -78
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -130
- data/lib/selenium/webdriver/remote/commands.rb +0 -211
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -668
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -236
- data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -132
- data/lib/selenium/webdriver/safari/resources/client.js +0 -7255
- data/lib/selenium/webdriver/safari/server.rb +0 -187
- data/lib/selenium-client.rb +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
|
5
5
|
# distributed with this work for additional information
|
|
@@ -20,104 +20,32 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module Edge
|
|
23
|
-
|
|
24
23
|
#
|
|
25
24
|
# @api private
|
|
26
25
|
#
|
|
27
26
|
|
|
28
|
-
class Service
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def self.default_service(*extra_args)
|
|
51
|
-
new executable_path, DEFAULT_PORT, *extra_args
|
|
27
|
+
class Service < WebDriver::Service
|
|
28
|
+
@default_port = 17556
|
|
29
|
+
@executable = 'MicrosoftWebDriver'
|
|
30
|
+
@missing_text = <<~ERROR
|
|
31
|
+
Unable to find MicrosoftWebDriver. Please download the server from
|
|
32
|
+
https://www.microsoft.com/en-us/download/details.aspx?id=48212 and place it somewhere on your PATH.
|
|
33
|
+
More info at https://github.com/SeleniumHQ/selenium/wiki/MicrosoftWebDriver.
|
|
34
|
+
ERROR
|
|
35
|
+
@shutdown_supported = true
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
# Note: This processing is deprecated
|
|
40
|
+
def extract_service_args(driver_opts)
|
|
41
|
+
driver_args = super
|
|
42
|
+
driver_opts = driver_opts.dup
|
|
43
|
+
driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key? :host
|
|
44
|
+
driver_args << "--package=#{driver_opts[:package]}" if driver_opts.key? :package
|
|
45
|
+
driver_args << "--silent" if driver_opts[:silent] == true
|
|
46
|
+
driver_args << "--verbose" if driver_opts[:verbose] == true
|
|
47
|
+
driver_args
|
|
52
48
|
end
|
|
53
|
-
|
|
54
|
-
def initialize(executable_path, port, *extra_args)
|
|
55
|
-
@executable_path = executable_path
|
|
56
|
-
@host = Platform.localhost
|
|
57
|
-
@port = Integer(port)
|
|
58
|
-
|
|
59
|
-
raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
|
|
60
|
-
|
|
61
|
-
@extra_args = extra_args
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def start
|
|
65
|
-
Platform.exit_hook { stop } # make sure we don't leave the server running
|
|
66
|
-
|
|
67
|
-
socket_lock.locked do
|
|
68
|
-
find_free_port
|
|
69
|
-
start_process
|
|
70
|
-
connect_until_stable
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def stop
|
|
75
|
-
return if @process.nil? || @process.exited?
|
|
76
|
-
|
|
77
|
-
Net::HTTP.start(@host, @port) do |http|
|
|
78
|
-
http.open_timeout = STOP_TIMEOUT / 2
|
|
79
|
-
http.read_timeout = STOP_TIMEOUT / 2
|
|
80
|
-
|
|
81
|
-
http.head("/shutdown")
|
|
82
|
-
end
|
|
83
|
-
ensure
|
|
84
|
-
stop_process
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def uri
|
|
88
|
-
URI.parse "http://#{@host}:#{@port}"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def find_free_port
|
|
92
|
-
@port = PortProber.above @port
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def start_process
|
|
96
|
-
server_command = [@executable_path, "--port=#{@port}", *@extra_args]
|
|
97
|
-
@process = ChildProcess.build(*server_command)
|
|
98
|
-
|
|
99
|
-
@process.io.inherit! if $DEBUG == true
|
|
100
|
-
@process.start
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def stop_process
|
|
104
|
-
@process.poll_for_exit STOP_TIMEOUT
|
|
105
|
-
rescue ChildProcess::TimeoutError
|
|
106
|
-
@process.stop STOP_TIMEOUT
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def connect_until_stable
|
|
110
|
-
socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
|
|
111
|
-
|
|
112
|
-
unless socket_poller.connected?
|
|
113
|
-
raise Error::WebDriverError, "unable to connect to MicrosoftWebDriver #{@host}:#{@port}"
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
def socket_lock
|
|
118
|
-
@socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
49
|
end # Service
|
|
122
50
|
end # Edge
|
|
123
51
|
end # WebDriver
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
|
5
5
|
# distributed with this work for additional information
|
|
@@ -19,26 +19,26 @@
|
|
|
19
19
|
|
|
20
20
|
require 'net/http'
|
|
21
21
|
|
|
22
|
-
require 'selenium/webdriver/edge/service'
|
|
23
22
|
require 'selenium/webdriver/edge/bridge'
|
|
23
|
+
require 'selenium/webdriver/edge/driver'
|
|
24
|
+
require 'selenium/webdriver/edge/options'
|
|
24
25
|
|
|
25
26
|
module Selenium
|
|
26
27
|
module WebDriver
|
|
27
|
-
|
|
28
28
|
module Edge
|
|
29
29
|
def self.driver_path=(path)
|
|
30
|
-
|
|
30
|
+
WebDriver.logger.deprecate 'Selenium::WebDriver::Edge#driver_path=',
|
|
31
|
+
'Selenium::WebDriver::Edge::Service#driver_path='
|
|
32
|
+
Selenium::WebDriver::Edge::Service.driver_path = path
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
def self.
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
def self.driver_path
|
|
36
|
+
WebDriver.logger.deprecate 'Selenium::WebDriver::Edge#driver_path',
|
|
37
|
+
'Selenium::WebDriver::Edge::Service#driver_path'
|
|
38
|
+
Selenium::WebDriver::Edge::Service.driver_path
|
|
36
39
|
end
|
|
37
|
-
|
|
38
|
-
def self.path
|
|
39
|
-
@path ||= nil
|
|
40
|
-
end
|
|
41
|
-
|
|
42
40
|
end # Edge
|
|
43
41
|
end # WebDriver
|
|
44
42
|
end # Selenium
|
|
43
|
+
|
|
44
|
+
require 'selenium/webdriver/edge/service'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
|
5
5
|
# distributed with this work for additional information
|
|
@@ -20,42 +20,40 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module Firefox
|
|
23
|
-
|
|
24
23
|
# @api private
|
|
25
24
|
class Binary
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/x86/#{NO_FOCUS_LIBRARY_NAME}",
|
|
31
|
-
|
|
25
|
+
NO_FOCUS_LIBRARY_NAME = 'x_ignore_nofocus.so'
|
|
26
|
+
NO_FOCUS_LIBRARIES = [
|
|
27
|
+
["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/amd64/#{NO_FOCUS_LIBRARY_NAME}",
|
|
28
|
+
"amd64/#{NO_FOCUS_LIBRARY_NAME}"],
|
|
29
|
+
["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/x86/#{NO_FOCUS_LIBRARY_NAME}",
|
|
30
|
+
"x86/#{NO_FOCUS_LIBRARY_NAME}"]
|
|
31
|
+
].freeze
|
|
32
32
|
|
|
33
33
|
WAIT_TIMEOUT = 90
|
|
34
34
|
QUIT_TIMEOUT = 5
|
|
35
35
|
|
|
36
36
|
def start_with(profile, profile_path, *args)
|
|
37
37
|
if Platform.cygwin?
|
|
38
|
-
profile_path = Platform.cygwin_path(profile_path, :
|
|
38
|
+
profile_path = Platform.cygwin_path(profile_path, windows: true)
|
|
39
39
|
elsif Platform.windows?
|
|
40
|
-
profile_path =
|
|
40
|
+
profile_path = Platform.windows_path(profile_path)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
ENV['XRE_CONSOLE_LOG']
|
|
44
|
-
ENV['XRE_PROFILE_PATH']
|
|
45
|
-
ENV['MOZ_NO_REMOTE']
|
|
43
|
+
ENV['XRE_CONSOLE_LOG'] = profile.log_file if profile.log_file
|
|
44
|
+
ENV['XRE_PROFILE_PATH'] = profile_path
|
|
45
|
+
ENV['MOZ_NO_REMOTE'] = '1' # able to launch multiple instances
|
|
46
46
|
ENV['MOZ_CRASHREPORTER_DISABLE'] = '1' # disable breakpad
|
|
47
|
-
ENV['NO_EM_RESTART']
|
|
47
|
+
ENV['NO_EM_RESTART'] = '1' # prevent the binary from detaching from the console
|
|
48
48
|
|
|
49
|
-
if Platform.linux? && (profile.native_events? || profile.load_no_focus_lib?)
|
|
50
|
-
modify_link_library_path profile_path
|
|
51
|
-
end
|
|
49
|
+
modify_link_library_path profile_path if Platform.linux? && (profile.native_events? || profile.load_no_focus_lib?)
|
|
52
50
|
|
|
53
51
|
execute(*args)
|
|
54
|
-
cope_with_mac_strangeness(args) if Platform.mac?
|
|
55
52
|
end
|
|
56
53
|
|
|
57
54
|
def quit
|
|
58
55
|
return unless @process
|
|
56
|
+
|
|
59
57
|
@process.poll_for_exit QUIT_TIMEOUT
|
|
60
58
|
rescue ChildProcess::TimeoutError
|
|
61
59
|
# ok, force quit
|
|
@@ -76,26 +74,12 @@ module Selenium
|
|
|
76
74
|
private
|
|
77
75
|
|
|
78
76
|
def execute(*extra_args)
|
|
79
|
-
args = [self.class.path,
|
|
77
|
+
args = [self.class.path, '-no-remote'] + extra_args
|
|
80
78
|
@process = ChildProcess.build(*args)
|
|
81
|
-
|
|
82
|
-
@process.start
|
|
83
|
-
end
|
|
79
|
+
WebDriver.logger.debug("Executing Process #{args}")
|
|
84
80
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if @process.crashed?
|
|
89
|
-
# ok, trying a restart
|
|
90
|
-
sleep 7
|
|
91
|
-
execute(*args)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# ensure we're ok
|
|
95
|
-
sleep 0.3
|
|
96
|
-
if @process.crashed?
|
|
97
|
-
raise Error::WebDriverError, "unable to start Firefox cleanly, args: #{args.inspect}"
|
|
98
|
-
end
|
|
81
|
+
@process.io.stdout = @process.io.stderr = WebDriver.logger.io if WebDriver.logger.debug?
|
|
82
|
+
@process.start
|
|
99
83
|
end
|
|
100
84
|
|
|
101
85
|
def modify_link_library_path(profile_path)
|
|
@@ -112,11 +96,10 @@ module Selenium
|
|
|
112
96
|
paths += ENV['LD_LIBRARY_PATH'].to_s.split(File::PATH_SEPARATOR)
|
|
113
97
|
|
|
114
98
|
ENV['LD_LIBRARY_PATH'] = paths.uniq.join(File::PATH_SEPARATOR)
|
|
115
|
-
ENV['LD_PRELOAD']
|
|
99
|
+
ENV['LD_PRELOAD'] = NO_FOCUS_LIBRARY_NAME
|
|
116
100
|
end
|
|
117
101
|
|
|
118
102
|
class << self
|
|
119
|
-
|
|
120
103
|
#
|
|
121
104
|
# @api private
|
|
122
105
|
#
|
|
@@ -139,15 +122,17 @@ module Selenium
|
|
|
139
122
|
when :windows
|
|
140
123
|
windows_path
|
|
141
124
|
when :linux, :unix
|
|
142
|
-
Platform.find_binary(
|
|
125
|
+
Platform.find_binary('firefox3', 'firefox2', 'firefox') || '/usr/bin/firefox'
|
|
143
126
|
else
|
|
144
127
|
raise Error::WebDriverError, "unknown platform: #{Platform.os}"
|
|
145
128
|
end
|
|
146
129
|
|
|
147
|
-
@path = Platform.cygwin_path(@path) if Platform.cygwin?
|
|
130
|
+
@path = Platform.cygwin_path(@path, windows: true) if Platform.cygwin?
|
|
148
131
|
|
|
149
132
|
unless File.file?(@path.to_s)
|
|
150
|
-
|
|
133
|
+
error = "Could not find Firefox binary (os=#{Platform.os}). " \
|
|
134
|
+
"Make sure Firefox is installed or set the path manually with #{self}.path="
|
|
135
|
+
raise Error::WebDriverError, error
|
|
151
136
|
end
|
|
152
137
|
|
|
153
138
|
@path
|
|
@@ -155,27 +140,29 @@ module Selenium
|
|
|
155
140
|
|
|
156
141
|
def version
|
|
157
142
|
@version = case Platform.os
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
143
|
+
when :macosx
|
|
144
|
+
`#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
|
|
145
|
+
when :windows
|
|
146
|
+
`\"#{path}\" -v | more`.strip[/[^\s]*$/][/^\d+/].to_i
|
|
147
|
+
when :linux
|
|
148
|
+
`#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
|
|
149
|
+
else
|
|
150
|
+
0
|
|
151
|
+
end
|
|
167
152
|
end
|
|
168
153
|
|
|
169
154
|
private
|
|
170
155
|
|
|
171
156
|
def windows_path
|
|
172
|
-
windows_registry_path ||
|
|
157
|
+
windows_registry_path ||
|
|
158
|
+
Platform.find_in_program_files('\\Mozilla Firefox\\firefox.exe') ||
|
|
159
|
+
Platform.find_binary('firefox')
|
|
173
160
|
end
|
|
174
161
|
|
|
175
162
|
def macosx_path
|
|
176
|
-
path =
|
|
177
|
-
path = File.expand_path(
|
|
178
|
-
path = Platform.find_binary(
|
|
163
|
+
path = '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
|
|
164
|
+
path = File.expand_path('~/Applications/Firefox.app/Contents/MacOS/firefox-bin') unless File.exist?(path)
|
|
165
|
+
path = Platform.find_binary('firefox-bin') unless File.exist?(path)
|
|
179
166
|
|
|
180
167
|
path
|
|
181
168
|
end
|
|
@@ -184,18 +171,16 @@ module Selenium
|
|
|
184
171
|
require 'win32/registry'
|
|
185
172
|
|
|
186
173
|
lm = Win32::Registry::HKEY_LOCAL_MACHINE
|
|
187
|
-
lm.open(
|
|
174
|
+
lm.open('SOFTWARE\\Mozilla\\Mozilla Firefox') do |reg|
|
|
188
175
|
main = lm.open("SOFTWARE\\Mozilla\\Mozilla Firefox\\#{reg.keys[0]}\\Main")
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
end
|
|
176
|
+
entry = main.find { |key, _type, _data| key =~ /pathtoexe/i }
|
|
177
|
+
return entry.last if entry
|
|
192
178
|
end
|
|
193
179
|
rescue LoadError
|
|
194
180
|
# older JRuby or IronRuby does not have win32/registry
|
|
195
181
|
rescue Win32::Registry::Error
|
|
196
182
|
end
|
|
197
183
|
end # class << self
|
|
198
|
-
|
|
199
184
|
end # Binary
|
|
200
185
|
end # Firefox
|
|
201
186
|
end # WebDriver
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
|
|
20
|
+
module Selenium
|
|
21
|
+
module WebDriver
|
|
22
|
+
module Firefox
|
|
23
|
+
module Driver
|
|
24
|
+
class << self
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# Instantiates correct Firefox driver implementation
|
|
28
|
+
# @return [Marionette::Driver, Legacy::Driver]
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
def new(**opts)
|
|
32
|
+
if marionette?(opts)
|
|
33
|
+
Firefox::Marionette::Driver.new(opts)
|
|
34
|
+
else
|
|
35
|
+
Firefox::Legacy::Driver.new(opts)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def marionette?(opts)
|
|
42
|
+
opts.delete(:marionette) != false &&
|
|
43
|
+
(!opts[:desired_capabilities] || opts[:desired_capabilities][:marionette] != false)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end # Driver
|
|
48
|
+
end # Firefox
|
|
49
|
+
end # WebDriver
|
|
50
|
+
end # Selenium
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"extensions.autoDisableScopes": 10,
|
|
30
30
|
"extensions.blocklist.enabled": false,
|
|
31
31
|
"extensions.checkCompatibility.nightly": false,
|
|
32
|
-
"extensions.logging.enabled": true,
|
|
33
32
|
"extensions.update.enabled": false,
|
|
34
33
|
"extensions.update.notifyUser": false,
|
|
35
34
|
"javascript.enabled": true,
|
|
@@ -37,18 +36,8 @@
|
|
|
37
36
|
"network.http.phishy-userpass-length": 255,
|
|
38
37
|
"offline-apps.allow_by_default": true,
|
|
39
38
|
"prompts.tab_modal.enabled": false,
|
|
40
|
-
"security.csp.enable": false,
|
|
41
39
|
"security.fileuri.origin_policy": 3,
|
|
42
40
|
"security.fileuri.strict_origin_policy": false,
|
|
43
|
-
"security.warn_entering_secure": false,
|
|
44
|
-
"security.warn_entering_secure.show_once": false,
|
|
45
|
-
"security.warn_entering_weak": false,
|
|
46
|
-
"security.warn_entering_weak.show_once": false,
|
|
47
|
-
"security.warn_leaving_secure": false,
|
|
48
|
-
"security.warn_leaving_secure.show_once": false,
|
|
49
|
-
"security.warn_submit_insecure": false,
|
|
50
|
-
"security.warn_viewing_mixed": false,
|
|
51
|
-
"security.warn_viewing_mixed.show_once": false,
|
|
52
41
|
"signon.rememberSignons": false,
|
|
53
42
|
"toolkit.networkmanager.disable": true,
|
|
54
43
|
"toolkit.telemetry.prompted": 2,
|
|
@@ -64,12 +53,14 @@
|
|
|
64
53
|
"browser.newtabpage.enabled": false,
|
|
65
54
|
"browser.startup.page": 0,
|
|
66
55
|
"browser.startup.homepage": "about:blank",
|
|
56
|
+
"browser.startup.homepage_override.mstone": "ignore",
|
|
67
57
|
"browser.usedOnWindows10.introURL": "about:blank",
|
|
68
58
|
"dom.max_chrome_script_run_time": 30,
|
|
69
59
|
"dom.max_script_run_time": 30,
|
|
70
60
|
"dom.report_all_js_exceptions": true,
|
|
71
61
|
"javascript.options.showInConsole": true,
|
|
72
|
-
"network.
|
|
62
|
+
"network.captive-portal-service.enabled": false,
|
|
63
|
+
"security.csp.enable": false,
|
|
73
64
|
"startup.homepage_welcome_url": "about:blank",
|
|
74
65
|
"startup.homepage_welcome_url.additional": "about:blank",
|
|
75
66
|
"webdriver_accept_untrusted_certs": true,
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
|
5
5
|
# distributed with this work for additional information
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module Firefox
|
|
23
|
-
|
|
24
23
|
#
|
|
25
24
|
# @api private
|
|
26
25
|
#
|
|
@@ -29,9 +28,7 @@ module Selenium
|
|
|
29
28
|
NAMESPACE = 'http://www.mozilla.org/2004/em-rdf#'
|
|
30
29
|
|
|
31
30
|
def initialize(path)
|
|
32
|
-
unless File.exist?(path)
|
|
33
|
-
raise Error::WebDriverError, "could not find extension at #{path.inspect}"
|
|
34
|
-
end
|
|
31
|
+
raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.exist?(path)
|
|
35
32
|
|
|
36
33
|
@path = path
|
|
37
34
|
@should_reap_root = false
|
|
@@ -39,10 +36,10 @@ module Selenium
|
|
|
39
36
|
|
|
40
37
|
def write_to(extensions_dir)
|
|
41
38
|
root_dir = create_root
|
|
42
|
-
ext_path = File.join extensions_dir,
|
|
39
|
+
ext_path = File.join extensions_dir, read_id(root_dir)
|
|
43
40
|
|
|
44
41
|
FileUtils.rm_rf ext_path
|
|
45
|
-
FileUtils.mkdir_p File.dirname(ext_path), :
|
|
42
|
+
FileUtils.mkdir_p File.dirname(ext_path), mode: 0o700
|
|
46
43
|
FileUtils.cp_r root_dir, ext_path
|
|
47
44
|
|
|
48
45
|
FileReaper.reap(root_dir) if @should_reap_root
|
|
@@ -55,7 +52,7 @@ module Selenium
|
|
|
55
52
|
@path
|
|
56
53
|
else
|
|
57
54
|
unless Zipper::EXTENSIONS.include? File.extname(@path)
|
|
58
|
-
raise Error::WebDriverError, "expected #{Zipper::EXTENSIONS.join(
|
|
55
|
+
raise Error::WebDriverError, "expected #{Zipper::EXTENSIONS.join(' or ')}, got #{@path.inspect}"
|
|
59
56
|
end
|
|
60
57
|
|
|
61
58
|
@should_reap_root = true
|
|
@@ -63,8 +60,14 @@ module Selenium
|
|
|
63
60
|
end
|
|
64
61
|
end
|
|
65
62
|
|
|
63
|
+
def read_id(directory)
|
|
64
|
+
read_id_from_install_rdf(directory) || read_id_from_manifest_json(directory)
|
|
65
|
+
end
|
|
66
|
+
|
|
66
67
|
def read_id_from_install_rdf(directory)
|
|
67
|
-
rdf_path = File.join(directory,
|
|
68
|
+
rdf_path = File.join(directory, 'install.rdf')
|
|
69
|
+
return unless File.exist?(rdf_path)
|
|
70
|
+
|
|
68
71
|
doc = REXML::Document.new(File.read(rdf_path))
|
|
69
72
|
namespace = doc.root.namespaces.key(NAMESPACE)
|
|
70
73
|
|
|
@@ -79,6 +82,13 @@ module Selenium
|
|
|
79
82
|
raise Error::WebDriverError, "cannot locate extension id in #{rdf_path}"
|
|
80
83
|
end
|
|
81
84
|
|
|
85
|
+
def read_id_from_manifest_json(directory)
|
|
86
|
+
manifest_path = File.join(directory, 'manifest.json')
|
|
87
|
+
return unless File.exist?(manifest_path)
|
|
88
|
+
|
|
89
|
+
manifest = JSON.parse(File.read(manifest_path))
|
|
90
|
+
[manifest['name'].delete(' '), manifest['version']].join('@')
|
|
91
|
+
end
|
|
82
92
|
end # Extension
|
|
83
93
|
end # Firefox
|
|
84
94
|
end # WebDriver
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
|
5
5
|
# distributed with this work for additional information
|
|
@@ -20,10 +20,8 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module Firefox
|
|
23
|
-
|
|
24
23
|
# @api private
|
|
25
24
|
class Launcher
|
|
26
|
-
|
|
27
25
|
SOCKET_LOCK_TIMEOUT = 45
|
|
28
26
|
STABLE_CONNECTION_TIMEOUT = 60
|
|
29
27
|
|
|
@@ -33,14 +31,14 @@ module Selenium
|
|
|
33
31
|
|
|
34
32
|
raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
|
|
35
33
|
|
|
36
|
-
if profile.
|
|
34
|
+
if profile.is_a? Profile
|
|
37
35
|
@profile = profile
|
|
38
36
|
else
|
|
39
37
|
@profile_name = profile
|
|
40
38
|
@profile = nil
|
|
41
39
|
end
|
|
42
40
|
|
|
43
|
-
@host =
|
|
41
|
+
@host = '127.0.0.1'
|
|
44
42
|
end
|
|
45
43
|
|
|
46
44
|
def url
|
|
@@ -79,38 +77,34 @@ module Selenium
|
|
|
79
77
|
|
|
80
78
|
def start
|
|
81
79
|
assert_profile
|
|
82
|
-
@binary.start_with @profile, @profile_dir,
|
|
80
|
+
@binary.start_with @profile, @profile_dir, '-foreground'
|
|
83
81
|
end
|
|
84
82
|
|
|
85
83
|
def connect_until_stable
|
|
86
84
|
poller = SocketPoller.new(@host, @port, STABLE_CONNECTION_TIMEOUT)
|
|
87
85
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
return if poller.connected?
|
|
87
|
+
|
|
88
|
+
@binary.quit
|
|
89
|
+
error = "unable to obtain stable firefox connection in #{STABLE_CONNECTION_TIMEOUT} seconds (#{@host}:#{@port})"
|
|
90
|
+
raise Error::WebDriverError, error
|
|
92
91
|
end
|
|
93
92
|
|
|
94
93
|
def fetch_profile
|
|
95
|
-
if @profile_name
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
end
|
|
101
|
-
else
|
|
102
|
-
@profile = Profile.new
|
|
103
|
-
end
|
|
94
|
+
@profile = if @profile_name
|
|
95
|
+
Profile.from_name @profile_name
|
|
96
|
+
else
|
|
97
|
+
Profile.new
|
|
98
|
+
end
|
|
104
99
|
end
|
|
105
100
|
|
|
106
101
|
def assert_profile
|
|
107
|
-
raise Error::WebDriverError,
|
|
102
|
+
raise Error::WebDriverError, 'must create_profile first' unless @profile && @profile_dir
|
|
108
103
|
end
|
|
109
104
|
|
|
110
105
|
def socket_lock
|
|
111
106
|
@socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
|
|
112
107
|
end
|
|
113
|
-
|
|
114
108
|
end # Launcher
|
|
115
109
|
end # Firefox
|
|
116
110
|
end # WebDriver
|