selenium-webdriver 3.0.0.beta4.0 → 4.0.0.alpha5
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 +679 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/selenium-webdriver.rb +2 -2
- data/lib/selenium/server.rb +23 -16
- data/lib/selenium/webdriver.rb +43 -25
- data/lib/selenium/webdriver/atoms.rb +20 -1
- data/lib/selenium/webdriver/atoms/findElements.js +122 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +84 -11
- data/lib/selenium/webdriver/atoms/isDisplayed.js +100 -0
- data/lib/selenium/webdriver/chrome.rb +15 -20
- data/lib/selenium/webdriver/chrome/bridge.rb +29 -66
- data/lib/selenium/webdriver/{edge/service.rb → chrome/driver.rb} +19 -22
- data/lib/selenium/webdriver/chrome/options.rb +221 -0
- data/lib/selenium/webdriver/chrome/profile.rb +6 -7
- data/lib/selenium/webdriver/chrome/service.rb +20 -20
- data/lib/selenium/webdriver/common.rb +19 -11
- data/lib/selenium/webdriver/common/action_builder.rb +98 -246
- data/lib/selenium/webdriver/common/alert.rb +2 -7
- data/lib/selenium/webdriver/common/driver.rb +89 -51
- 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} +12 -25
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +38 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +3 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +3 -3
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -2
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +4 -4
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -3
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -5
- data/lib/selenium/webdriver/common/element.rb +32 -10
- data/lib/selenium/webdriver/common/error.rb +103 -121
- data/lib/selenium/webdriver/common/file_reaper.rb +3 -5
- data/lib/selenium/webdriver/common/html5/local_storage.rb +2 -2
- data/lib/selenium/webdriver/common/html5/session_storage.rb +2 -2
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +3 -2
- 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/{phantomjs.rb → common/interactions/interactions.rb} +17 -20
- 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/common/interactions/none_input.rb +36 -0
- 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/keys.rb +37 -15
- data/lib/selenium/webdriver/common/log_entry.rb +4 -4
- data/lib/selenium/webdriver/common/logger.rb +147 -0
- data/lib/selenium/webdriver/common/logs.rb +2 -2
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/navigation.rb +2 -2
- data/lib/selenium/webdriver/common/options.rb +47 -105
- data/lib/selenium/webdriver/common/platform.rb +44 -38
- data/lib/selenium/webdriver/common/port_prober.rb +8 -19
- data/lib/selenium/webdriver/common/profile_helper.rb +13 -5
- data/lib/selenium/webdriver/common/proxy.rb +14 -8
- data/lib/selenium/webdriver/common/search_context.rb +16 -20
- data/lib/selenium/webdriver/common/service.rb +115 -30
- data/lib/selenium/webdriver/common/socket_lock.rb +12 -7
- data/lib/selenium/webdriver/common/socket_poller.rb +29 -22
- data/lib/selenium/webdriver/common/target_locator.rb +6 -6
- data/lib/selenium/webdriver/common/timeouts.rb +2 -2
- data/lib/selenium/webdriver/common/wait.rb +14 -8
- data/lib/selenium/webdriver/common/window.rb +38 -2
- data/lib/selenium/webdriver/common/zipper.rb +3 -5
- data/lib/selenium/webdriver/edge.rb +33 -20
- data/lib/selenium/webdriver/edge_chrome/bridge.rb +30 -0
- data/lib/selenium/webdriver/edge_chrome/driver.rb +38 -0
- data/lib/selenium/webdriver/{common/driver_extensions/has_touch_screen.rb → edge_chrome/options.rb} +10 -12
- data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
- data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
- data/lib/selenium/webdriver/edge_html/driver.rb +39 -0
- data/lib/selenium/webdriver/edge_html/options.rb +91 -0
- data/lib/selenium/webdriver/edge_html/service.rb +47 -0
- data/lib/selenium/webdriver/firefox.rb +24 -29
- data/lib/selenium/webdriver/firefox/bridge.rb +15 -39
- data/lib/selenium/webdriver/firefox/{util.rb → driver.rb} +13 -19
- data/lib/selenium/webdriver/firefox/extension.rb +28 -8
- data/lib/selenium/webdriver/firefox/options.rb +162 -0
- data/lib/selenium/webdriver/firefox/profile.rb +23 -82
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +5 -5
- data/lib/selenium/webdriver/firefox/service.rb +18 -37
- data/lib/selenium/webdriver/ie.rb +13 -19
- data/lib/selenium/webdriver/ie/driver.rb +40 -0
- data/lib/selenium/webdriver/ie/options.rb +118 -0
- data/lib/selenium/webdriver/ie/service.rb +20 -20
- data/lib/selenium/webdriver/remote.rb +15 -17
- data/lib/selenium/webdriver/remote/bridge.rb +281 -300
- data/lib/selenium/webdriver/remote/capabilities.rb +102 -83
- data/lib/selenium/webdriver/remote/commands.rb +132 -192
- data/lib/selenium/webdriver/remote/driver.rb +52 -0
- data/lib/selenium/webdriver/remote/http/common.rb +23 -13
- data/lib/selenium/webdriver/remote/http/curb.rb +10 -7
- data/lib/selenium/webdriver/remote/http/default.rb +52 -32
- data/lib/selenium/webdriver/remote/http/persistent.rb +8 -4
- data/lib/selenium/webdriver/remote/response.rb +32 -35
- data/lib/selenium/webdriver/remote/server_error.rb +2 -2
- data/lib/selenium/webdriver/safari.rb +24 -22
- data/lib/selenium/webdriver/safari/bridge.rb +21 -21
- data/lib/selenium/webdriver/safari/driver.rb +41 -0
- data/lib/selenium/webdriver/safari/options.rb +66 -0
- data/lib/selenium/webdriver/safari/service.rb +8 -24
- data/lib/selenium/webdriver/support.rb +3 -2
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +2 -2
- data/lib/selenium/webdriver/support/block_event_listener.rb +3 -3
- data/lib/selenium/webdriver/support/color.rb +13 -13
- data/lib/selenium/webdriver/support/escaper.rb +2 -2
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
- data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
- data/lib/selenium/webdriver/support/select.rb +20 -21
- data/lib/selenium/webdriver/version.rb +24 -0
- data/selenium-webdriver.gemspec +31 -17
- metadata +331 -248
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/keyboard.rb +0 -69
- data/lib/selenium/webdriver/common/mouse.rb +0 -88
- data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -81
- data/lib/selenium/webdriver/common/touch_screen.rb +0 -121
- data/lib/selenium/webdriver/common/w3c_error.rb +0 -191
- data/lib/selenium/webdriver/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
- data/lib/selenium/webdriver/firefox/binary.rb +0 -186
- data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +0 -114
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/w3c_bridge.rb +0 -79
- data/lib/selenium/webdriver/ie/bridge.rb +0 -76
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -65
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -66
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -682
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -228
- data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -135
|
@@ -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
|
|
@@ -25,12 +25,10 @@ module Selenium
|
|
|
25
25
|
#
|
|
26
26
|
|
|
27
27
|
class Extension
|
|
28
|
-
NAMESPACE = 'http://www.mozilla.org/2004/em-rdf#'
|
|
28
|
+
NAMESPACE = 'http://www.mozilla.org/2004/em-rdf#'
|
|
29
29
|
|
|
30
30
|
def initialize(path)
|
|
31
|
-
unless File.exist?(path)
|
|
32
|
-
raise Error::WebDriverError, "could not find extension at #{path.inspect}"
|
|
33
|
-
end
|
|
31
|
+
raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.exist?(path)
|
|
34
32
|
|
|
35
33
|
@path = path
|
|
36
34
|
@should_reap_root = false
|
|
@@ -38,10 +36,10 @@ module Selenium
|
|
|
38
36
|
|
|
39
37
|
def write_to(extensions_dir)
|
|
40
38
|
root_dir = create_root
|
|
41
|
-
ext_path = File.join extensions_dir,
|
|
39
|
+
ext_path = File.join extensions_dir, read_id(root_dir)
|
|
42
40
|
|
|
43
41
|
FileUtils.rm_rf ext_path
|
|
44
|
-
FileUtils.mkdir_p File.dirname(ext_path), mode:
|
|
42
|
+
FileUtils.mkdir_p File.dirname(ext_path), mode: 0o700
|
|
45
43
|
FileUtils.cp_r root_dir, ext_path
|
|
46
44
|
|
|
47
45
|
FileReaper.reap(root_dir) if @should_reap_root
|
|
@@ -62,8 +60,14 @@ module Selenium
|
|
|
62
60
|
end
|
|
63
61
|
end
|
|
64
62
|
|
|
63
|
+
def read_id(directory)
|
|
64
|
+
read_id_from_install_rdf(directory) || read_id_from_manifest_json(directory)
|
|
65
|
+
end
|
|
66
|
+
|
|
65
67
|
def read_id_from_install_rdf(directory)
|
|
66
68
|
rdf_path = File.join(directory, 'install.rdf')
|
|
69
|
+
return unless File.exist?(rdf_path)
|
|
70
|
+
|
|
67
71
|
doc = REXML::Document.new(File.read(rdf_path))
|
|
68
72
|
namespace = doc.root.namespaces.key(NAMESPACE)
|
|
69
73
|
|
|
@@ -77,6 +81,22 @@ module Selenium
|
|
|
77
81
|
|
|
78
82
|
raise Error::WebDriverError, "cannot locate extension id in #{rdf_path}"
|
|
79
83
|
end
|
|
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
|
+
applications_gecko_id(manifest) || name_and_version(manifest)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def applications_gecko_id(manifest)
|
|
94
|
+
manifest.dig('applications', 'gecko', 'id')&.strip
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def name_and_version(manifest)
|
|
98
|
+
[manifest['name'].delete(' '), manifest['version']].join('@')
|
|
99
|
+
end
|
|
80
100
|
end # Extension
|
|
81
101
|
end # Firefox
|
|
82
102
|
end # WebDriver
|
|
@@ -0,0 +1,162 @@
|
|
|
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
|
+
class Options < WebDriver::Options
|
|
24
|
+
KEY = 'moz:firefoxOptions'
|
|
25
|
+
|
|
26
|
+
# see: https://firefox-source-docs.mozilla.org/testing/geckodriver/Capabilities.html
|
|
27
|
+
CAPABILITIES = {binary: 'binary',
|
|
28
|
+
args: 'args',
|
|
29
|
+
profile: 'profile',
|
|
30
|
+
log: 'log',
|
|
31
|
+
prefs: 'prefs'}.freeze
|
|
32
|
+
|
|
33
|
+
CAPABILITIES.each_key do |key|
|
|
34
|
+
define_method key do
|
|
35
|
+
@options[key]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
define_method "#{key}=" do |value|
|
|
39
|
+
@options[key] = value
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Create a new Options instance, only for W3C-capable versions of Firefox.
|
|
45
|
+
#
|
|
46
|
+
# @example
|
|
47
|
+
# options = Selenium::WebDriver::Firefox::Options.new(args: ['--host=127.0.0.1'])
|
|
48
|
+
# driver = Selenium::WebDriver.for :firefox, options: options
|
|
49
|
+
#
|
|
50
|
+
# @param [Hash] opts the pre-defined options to create the Firefox::Options with
|
|
51
|
+
# @option opts [String] :binary Path to the Firefox executable to use
|
|
52
|
+
# @option opts [Array<String>] :args List of command-line arguments to use when starting geckodriver
|
|
53
|
+
# @option opts [Profile, String] :profile Encoded profile string or Profile instance
|
|
54
|
+
# @option opts [String, Symbol] :log_level Log level for geckodriver
|
|
55
|
+
# @option opts [Hash] :prefs A hash with each entry consisting of the key of the preference and its value
|
|
56
|
+
# @option opts [Hash] :options A hash for raw options
|
|
57
|
+
#
|
|
58
|
+
|
|
59
|
+
def initialize(log_level: nil, **opts)
|
|
60
|
+
super(opts)
|
|
61
|
+
|
|
62
|
+
@options[:log] ||= {level: log_level} if log_level
|
|
63
|
+
process_profile(@options[:profile]) if @options.key?(:profile)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
#
|
|
67
|
+
# Add a command-line argument to use when starting Firefox.
|
|
68
|
+
#
|
|
69
|
+
# @example Start geckodriver on a specific host
|
|
70
|
+
# options = Selenium::WebDriver::Firefox::Options.new
|
|
71
|
+
# options.add_argument('--host=127.0.0.1')
|
|
72
|
+
#
|
|
73
|
+
# @param [String] arg The command-line argument to add
|
|
74
|
+
#
|
|
75
|
+
|
|
76
|
+
def add_argument(arg)
|
|
77
|
+
@options[:args] ||= []
|
|
78
|
+
@options[:args] << arg
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
#
|
|
82
|
+
# Add a preference that is only applied to the user profile in use.
|
|
83
|
+
#
|
|
84
|
+
# @example Set the default homepage
|
|
85
|
+
# options = Selenium::WebDriver::Firefox::Options.new
|
|
86
|
+
# options.add_preference('browser.startup.homepage', 'http://www.seleniumhq.com/')
|
|
87
|
+
#
|
|
88
|
+
# @param [String] name Key of the preference
|
|
89
|
+
# @param [Boolean, String, Integer] value Value of the preference
|
|
90
|
+
#
|
|
91
|
+
|
|
92
|
+
def add_preference(name, value)
|
|
93
|
+
@options[:prefs] ||= {}
|
|
94
|
+
@options[:prefs][name] = value
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
#
|
|
98
|
+
# Run Firefox in headless mode.
|
|
99
|
+
#
|
|
100
|
+
# @example Enable headless mode
|
|
101
|
+
# options = Selenium::WebDriver::Firefox::Options.new
|
|
102
|
+
# options.headless!
|
|
103
|
+
#
|
|
104
|
+
|
|
105
|
+
def headless!
|
|
106
|
+
add_argument '-headless'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# Sets Firefox profile.
|
|
111
|
+
#
|
|
112
|
+
# @example Set the custom profile
|
|
113
|
+
# profile = Selenium::WebDriver::Firefox::Profile.new
|
|
114
|
+
# options = Selenium::WebDriver::Firefox::Options.new
|
|
115
|
+
# options.profile = profile
|
|
116
|
+
#
|
|
117
|
+
# @example Use existing profile
|
|
118
|
+
# options = Selenium::WebDriver::Firefox::Options.new
|
|
119
|
+
# options.profile = 'myprofile'
|
|
120
|
+
#
|
|
121
|
+
# @param [Profile, String] profile Profile to be used
|
|
122
|
+
#
|
|
123
|
+
|
|
124
|
+
undef profile=
|
|
125
|
+
def profile=(profile)
|
|
126
|
+
process_profile(profile)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def log_level
|
|
130
|
+
@options.dig(:log, :level)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def log_level=(level)
|
|
134
|
+
@options[:log] = {level: level}
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
#
|
|
138
|
+
# @api private
|
|
139
|
+
#
|
|
140
|
+
|
|
141
|
+
def as_json(*)
|
|
142
|
+
options = super
|
|
143
|
+
options['binary'] ||= Firefox.path if Firefox.path
|
|
144
|
+
|
|
145
|
+
{KEY => generate_as_json(options)}
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
private
|
|
149
|
+
|
|
150
|
+
def process_profile(profile)
|
|
151
|
+
@options[:profile] = if profile.nil?
|
|
152
|
+
nil
|
|
153
|
+
elsif profile.is_a? Profile
|
|
154
|
+
profile
|
|
155
|
+
else
|
|
156
|
+
Profile.from_name(profile)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end # Options
|
|
160
|
+
end # Firefox
|
|
161
|
+
end # WebDriver
|
|
162
|
+
end # Selenium
|
|
@@ -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
|
|
@@ -23,18 +23,10 @@ module Selenium
|
|
|
23
23
|
class Profile
|
|
24
24
|
include ProfileHelper
|
|
25
25
|
|
|
26
|
-
VALID_PREFERENCE_TYPES
|
|
27
|
-
WEBDRIVER_EXTENSION_PATH = File.expand_path("#{WebDriver.root}/selenium/webdriver/firefox/extension/webdriver.xpi")
|
|
28
|
-
WEBDRIVER_PREFS = {
|
|
29
|
-
native_events: 'webdriver_enable_native_events',
|
|
30
|
-
untrusted_certs: 'webdriver_accept_untrusted_certs',
|
|
31
|
-
untrusted_issuer: 'webdriver_assume_untrusted_issuer',
|
|
32
|
-
port: 'webdriver_firefox_port',
|
|
33
|
-
log_file: 'webdriver.log.file'
|
|
34
|
-
}.freeze
|
|
26
|
+
VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String].freeze
|
|
35
27
|
|
|
36
28
|
attr_reader :name, :log_file
|
|
37
|
-
attr_writer :secure_ssl, :
|
|
29
|
+
attr_writer :secure_ssl, :load_no_focus_lib
|
|
38
30
|
|
|
39
31
|
class << self
|
|
40
32
|
def ini
|
|
@@ -42,13 +34,14 @@ module Selenium
|
|
|
42
34
|
end
|
|
43
35
|
|
|
44
36
|
def from_name(name)
|
|
45
|
-
ini[name]
|
|
37
|
+
profile = ini[name]
|
|
38
|
+
return profile if profile
|
|
39
|
+
|
|
40
|
+
raise Error::WebDriverError, "unable to find profile named: #{name.inspect}"
|
|
46
41
|
end
|
|
47
42
|
|
|
48
|
-
def
|
|
49
|
-
|
|
50
|
-
File.read(File.expand_path("#{WebDriver.root}/selenium/webdriver/firefox/extension/prefs.json"))
|
|
51
|
-
).freeze
|
|
43
|
+
def decoded(json)
|
|
44
|
+
JSON.parse(json)
|
|
52
45
|
end
|
|
53
46
|
end
|
|
54
47
|
|
|
@@ -67,25 +60,7 @@ module Selenium
|
|
|
67
60
|
def initialize(model = nil)
|
|
68
61
|
@model = verify_model(model)
|
|
69
62
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if model_prefs.empty?
|
|
73
|
-
@native_events = DEFAULT_ENABLE_NATIVE_EVENTS
|
|
74
|
-
@secure_ssl = DEFAULT_SECURE_SSL
|
|
75
|
-
@untrusted_issuer = DEFAULT_ASSUME_UNTRUSTED_ISSUER
|
|
76
|
-
@load_no_focus_lib = DEFAULT_LOAD_NO_FOCUS_LIB
|
|
77
|
-
|
|
78
|
-
@additional_prefs = {}
|
|
79
|
-
else
|
|
80
|
-
# TODO: clean this up
|
|
81
|
-
@native_events = model_prefs.delete(WEBDRIVER_PREFS[:native_events]) == 'true'
|
|
82
|
-
@secure_ssl = model_prefs.delete(WEBDRIVER_PREFS[:untrusted_certs]) != 'true'
|
|
83
|
-
@untrusted_issuer = model_prefs.delete(WEBDRIVER_PREFS[:untrusted_issuer]) == 'true'
|
|
84
|
-
# not stored in profile atm, so will always be false.
|
|
85
|
-
@load_no_focus_lib = model_prefs.delete(WEBDRIVER_PREFS[:load_no_focus_lib]) == 'true'
|
|
86
|
-
@additional_prefs = model_prefs
|
|
87
|
-
end
|
|
88
|
-
|
|
63
|
+
@additional_prefs = read_model_prefs
|
|
89
64
|
@extensions = {}
|
|
90
65
|
end
|
|
91
66
|
|
|
@@ -113,7 +88,7 @@ module Selenium
|
|
|
113
88
|
raise TypeError, "expected one of #{VALID_PREFERENCE_TYPES.inspect}, got #{value.inspect}:#{value.class}"
|
|
114
89
|
end
|
|
115
90
|
|
|
116
|
-
if value.is_a?(String) &&
|
|
91
|
+
if value.is_a?(String) && stringified?(value)
|
|
117
92
|
raise ArgumentError, "preference values must be plain strings: #{key.inspect} => #{value.inspect}"
|
|
118
93
|
end
|
|
119
94
|
|
|
@@ -129,11 +104,6 @@ module Selenium
|
|
|
129
104
|
self[WEBDRIVER_PREFS[:log_file]] = file
|
|
130
105
|
end
|
|
131
106
|
|
|
132
|
-
def add_webdriver_extension
|
|
133
|
-
return if @extensions.key?(:webdriver)
|
|
134
|
-
add_extension(WEBDRIVER_EXTENSION_PATH, :webdriver)
|
|
135
|
-
end
|
|
136
|
-
|
|
137
107
|
#
|
|
138
108
|
# Add the extension (directory, .zip or .xpi) at the given path to the profile.
|
|
139
109
|
#
|
|
@@ -142,30 +112,8 @@ module Selenium
|
|
|
142
112
|
@extensions[name] = Extension.new(path)
|
|
143
113
|
end
|
|
144
114
|
|
|
145
|
-
def native_events?
|
|
146
|
-
@native_events == true
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def load_no_focus_lib?
|
|
150
|
-
@load_no_focus_lib == true
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def secure_ssl?
|
|
154
|
-
@secure_ssl == true
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def assume_untrusted_certificate_issuer?
|
|
158
|
-
@untrusted_issuer == true
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def assume_untrusted_certificate_issuer=(bool)
|
|
162
|
-
@untrusted_issuer = bool
|
|
163
|
-
end
|
|
164
|
-
|
|
165
115
|
def proxy=(proxy)
|
|
166
|
-
unless proxy.is_a? Proxy
|
|
167
|
-
raise TypeError, "expected #{Proxy.name}, got #{proxy.inspect}:#{proxy.class}"
|
|
168
|
-
end
|
|
116
|
+
raise TypeError, "expected #{Proxy.name}, got #{proxy.inspect}:#{proxy.class}" unless proxy.is_a? Proxy
|
|
169
117
|
|
|
170
118
|
case proxy.type
|
|
171
119
|
when :manual
|
|
@@ -176,11 +124,7 @@ module Selenium
|
|
|
176
124
|
set_manual_proxy_preference 'ssl', proxy.ssl
|
|
177
125
|
set_manual_proxy_preference 'socks', proxy.socks
|
|
178
126
|
|
|
179
|
-
self['network.proxy.no_proxies_on'] =
|
|
180
|
-
proxy.no_proxy
|
|
181
|
-
else
|
|
182
|
-
''
|
|
183
|
-
end
|
|
127
|
+
self['network.proxy.no_proxies_on'] = proxy.no_proxy || ''
|
|
184
128
|
when :pac
|
|
185
129
|
self['network.proxy.type'] = 2
|
|
186
130
|
self['network.proxy.autoconfig_url'] = proxy.pac
|
|
@@ -189,10 +133,10 @@ module Selenium
|
|
|
189
133
|
else
|
|
190
134
|
raise ArgumentError, "unsupported proxy type #{proxy.type}"
|
|
191
135
|
end
|
|
192
|
-
|
|
193
|
-
proxy
|
|
194
136
|
end
|
|
195
137
|
|
|
138
|
+
alias_method :as_json, :encoded
|
|
139
|
+
|
|
196
140
|
private
|
|
197
141
|
|
|
198
142
|
def set_manual_proxy_preference(key, value)
|
|
@@ -208,7 +152,7 @@ module Selenium
|
|
|
208
152
|
destination = File.join(directory, 'extensions')
|
|
209
153
|
|
|
210
154
|
@extensions.each do |name, extension|
|
|
211
|
-
|
|
155
|
+
WebDriver.logger.debug({extenstion: name}.inspect)
|
|
212
156
|
extension.write_to(destination)
|
|
213
157
|
end
|
|
214
158
|
end
|
|
@@ -235,15 +179,7 @@ module Selenium
|
|
|
235
179
|
|
|
236
180
|
def update_user_prefs_in(directory)
|
|
237
181
|
path = File.join(directory, 'user.js')
|
|
238
|
-
prefs = read_user_prefs(path)
|
|
239
|
-
|
|
240
|
-
prefs.merge! self.class.default_preferences.fetch 'mutable'
|
|
241
|
-
prefs.merge! @additional_prefs
|
|
242
|
-
prefs.merge! self.class.default_preferences.fetch 'frozen'
|
|
243
|
-
|
|
244
|
-
prefs[WEBDRIVER_PREFS[:untrusted_certs]] = !secure_ssl?
|
|
245
|
-
prefs[WEBDRIVER_PREFS[:native_events]] = native_events?
|
|
246
|
-
prefs[WEBDRIVER_PREFS[:untrusted_issuer]] = assume_untrusted_certificate_issuer?
|
|
182
|
+
prefs = read_user_prefs(path).merge(@additional_prefs)
|
|
247
183
|
|
|
248
184
|
# If the user sets the home page, we should also start up there
|
|
249
185
|
prefs['startup.homepage_welcome_url'] = prefs['browser.startup.homepage']
|
|
@@ -257,6 +193,7 @@ module Selenium
|
|
|
257
193
|
|
|
258
194
|
File.read(path).split("\n").each do |line|
|
|
259
195
|
next unless line =~ /user_pref\("([^"]+)"\s*,\s*(.+?)\);/
|
|
196
|
+
|
|
260
197
|
key = Regexp.last_match(1).strip
|
|
261
198
|
value = Regexp.last_match(2).strip
|
|
262
199
|
|
|
@@ -274,6 +211,10 @@ module Selenium
|
|
|
274
211
|
end
|
|
275
212
|
end
|
|
276
213
|
end
|
|
214
|
+
|
|
215
|
+
def stringified?(str)
|
|
216
|
+
/^".*"$/.match?(str)
|
|
217
|
+
end
|
|
277
218
|
end # Profile
|
|
278
219
|
end # Firefox
|
|
279
220
|
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
|
|
@@ -57,15 +57,15 @@ module Selenium
|
|
|
57
57
|
is_relative = Regexp.last_match(1).strip == '1'
|
|
58
58
|
when /^Path=(.+)$/
|
|
59
59
|
path = Regexp.last_match(1).strip
|
|
60
|
+
p = path_for(name, is_relative, path)
|
|
61
|
+
@profile_paths[name] = p if p
|
|
60
62
|
end
|
|
61
63
|
end
|
|
62
|
-
|
|
63
|
-
p = path_for(name, is_relative, path)
|
|
64
|
-
@profile_paths[name] = p if p
|
|
65
64
|
end
|
|
66
65
|
|
|
67
66
|
def path_for(name, is_relative, path)
|
|
68
67
|
return unless [name, path].any?
|
|
68
|
+
|
|
69
69
|
is_relative ? File.join(Util.app_data_path, path) : path
|
|
70
70
|
end
|
|
71
71
|
end # ProfilesIni
|