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
@@ -20,38 +20,37 @@
|
|
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'.freeze
|
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 = profile_path.
|
40
|
+
profile_path = profile_path.tr('/', '\\')
|
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
49
|
if Platform.linux? && (profile.native_events? || profile.load_no_focus_lib?)
|
50
50
|
modify_link_library_path profile_path
|
51
51
|
end
|
52
52
|
|
53
53
|
execute(*args)
|
54
|
-
cope_with_mac_strangeness(args) if Platform.mac?
|
55
54
|
end
|
56
55
|
|
57
56
|
def quit
|
@@ -76,28 +75,12 @@ module Selenium
|
|
76
75
|
private
|
77
76
|
|
78
77
|
def execute(*extra_args)
|
79
|
-
args = [self.class.path,
|
78
|
+
args = [self.class.path, '-no-remote'] + extra_args
|
80
79
|
@process = ChildProcess.build(*args)
|
81
80
|
@process.io.inherit! if $DEBUG
|
82
81
|
@process.start
|
83
82
|
end
|
84
83
|
|
85
|
-
def cope_with_mac_strangeness(args)
|
86
|
-
sleep 0.3
|
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
|
99
|
-
end
|
100
|
-
|
101
84
|
def modify_link_library_path(profile_path)
|
102
85
|
paths = []
|
103
86
|
|
@@ -112,11 +95,10 @@ module Selenium
|
|
112
95
|
paths += ENV['LD_LIBRARY_PATH'].to_s.split(File::PATH_SEPARATOR)
|
113
96
|
|
114
97
|
ENV['LD_LIBRARY_PATH'] = paths.uniq.join(File::PATH_SEPARATOR)
|
115
|
-
ENV['LD_PRELOAD']
|
98
|
+
ENV['LD_PRELOAD'] = NO_FOCUS_LIBRARY_NAME
|
116
99
|
end
|
117
100
|
|
118
101
|
class << self
|
119
|
-
|
120
102
|
#
|
121
103
|
# @api private
|
122
104
|
#
|
@@ -139,7 +121,7 @@ module Selenium
|
|
139
121
|
when :windows
|
140
122
|
windows_path
|
141
123
|
when :linux, :unix
|
142
|
-
Platform.find_binary(
|
124
|
+
Platform.find_binary('firefox3', 'firefox2', 'firefox') || '/usr/bin/firefox'
|
143
125
|
else
|
144
126
|
raise Error::WebDriverError, "unknown platform: #{Platform.os}"
|
145
127
|
end
|
@@ -147,7 +129,9 @@ module Selenium
|
|
147
129
|
@path = Platform.cygwin_path(@path) if Platform.cygwin?
|
148
130
|
|
149
131
|
unless File.file?(@path.to_s)
|
150
|
-
|
132
|
+
error = "Could not find Firefox binary (os=#{Platform.os}). "
|
133
|
+
error << "Make sure Firefox is installed or set the path manually with #{self}.path="
|
134
|
+
raise Error::WebDriverError, error
|
151
135
|
end
|
152
136
|
|
153
137
|
@path
|
@@ -155,27 +139,29 @@ module Selenium
|
|
155
139
|
|
156
140
|
def version
|
157
141
|
@version = case Platform.os
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
142
|
+
when :macosx
|
143
|
+
`#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
|
144
|
+
when :windows
|
145
|
+
`\"#{path}\" -v | more`.strip[/[^\s]*$/][/^\d+/].to_i
|
146
|
+
when :linux
|
147
|
+
`#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
|
148
|
+
else
|
149
|
+
0
|
150
|
+
end
|
167
151
|
end
|
168
152
|
|
169
153
|
private
|
170
154
|
|
171
155
|
def windows_path
|
172
|
-
windows_registry_path ||
|
156
|
+
windows_registry_path ||
|
157
|
+
Platform.find_in_program_files('\\Mozilla Firefox\\firefox.exe') ||
|
158
|
+
Platform.find_binary('firefox')
|
173
159
|
end
|
174
160
|
|
175
161
|
def macosx_path
|
176
|
-
path =
|
177
|
-
path = File.expand_path(
|
178
|
-
path = Platform.find_binary(
|
162
|
+
path = '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
|
163
|
+
path = File.expand_path('~/Applications/Firefox.app/Contents/MacOS/firefox-bin') unless File.exist?(path)
|
164
|
+
path = Platform.find_binary('firefox-bin') unless File.exist?(path)
|
179
165
|
|
180
166
|
path
|
181
167
|
end
|
@@ -184,18 +170,16 @@ module Selenium
|
|
184
170
|
require 'win32/registry'
|
185
171
|
|
186
172
|
lm = Win32::Registry::HKEY_LOCAL_MACHINE
|
187
|
-
lm.open(
|
173
|
+
lm.open('SOFTWARE\\Mozilla\\Mozilla Firefox') do |reg|
|
188
174
|
main = lm.open("SOFTWARE\\Mozilla\\Mozilla Firefox\\#{reg.keys[0]}\\Main")
|
189
|
-
|
190
|
-
|
191
|
-
end
|
175
|
+
entry = main.find { |key, _type, _data| key =~ /pathtoexe/i }
|
176
|
+
return entry.last if entry
|
192
177
|
end
|
193
178
|
rescue LoadError
|
194
179
|
# older JRuby or IronRuby does not have win32/registry
|
195
180
|
rescue Win32::Registry::Error
|
196
181
|
end
|
197
182
|
end # class << self
|
198
|
-
|
199
183
|
end # Binary
|
200
184
|
end # Firefox
|
201
185
|
end # WebDriver
|
@@ -20,10 +20,8 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Firefox
|
23
|
-
|
24
23
|
# @api private
|
25
24
|
class Bridge < Remote::Bridge
|
26
|
-
|
27
25
|
def initialize(opts = {})
|
28
26
|
port = opts.delete(:port) || DEFAULT_PORT
|
29
27
|
profile = opts.delete(:profile)
|
@@ -45,11 +43,11 @@ module Selenium
|
|
45
43
|
caps.proxy = proxy if proxy
|
46
44
|
|
47
45
|
remote_opts = {
|
48
|
-
:
|
49
|
-
:
|
46
|
+
url: @launcher.url,
|
47
|
+
desired_capabilities: caps
|
50
48
|
}
|
51
49
|
|
52
|
-
remote_opts
|
50
|
+
remote_opts[:http_client] = http_client if http_client
|
53
51
|
|
54
52
|
begin
|
55
53
|
super(remote_opts)
|
@@ -82,7 +80,6 @@ module Selenium
|
|
82
80
|
def create_launcher(port, profile)
|
83
81
|
Launcher.new Binary.new, port, profile
|
84
82
|
end
|
85
|
-
|
86
83
|
end # Bridge
|
87
84
|
end # Firefox
|
88
85
|
end # WebDriver
|
@@ -20,13 +20,12 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Firefox
|
23
|
-
|
24
23
|
#
|
25
24
|
# @api private
|
26
25
|
#
|
27
26
|
|
28
27
|
class Extension
|
29
|
-
NAMESPACE = 'http://www.mozilla.org/2004/em-rdf#'
|
28
|
+
NAMESPACE = 'http://www.mozilla.org/2004/em-rdf#'.freeze
|
30
29
|
|
31
30
|
def initialize(path)
|
32
31
|
unless File.exist?(path)
|
@@ -42,7 +41,7 @@ module Selenium
|
|
42
41
|
ext_path = File.join extensions_dir, read_id_from_install_rdf(root_dir)
|
43
42
|
|
44
43
|
FileUtils.rm_rf ext_path
|
45
|
-
FileUtils.mkdir_p File.dirname(ext_path), :
|
44
|
+
FileUtils.mkdir_p File.dirname(ext_path), mode: 0700
|
46
45
|
FileUtils.cp_r root_dir, ext_path
|
47
46
|
|
48
47
|
FileReaper.reap(root_dir) if @should_reap_root
|
@@ -55,7 +54,7 @@ module Selenium
|
|
55
54
|
@path
|
56
55
|
else
|
57
56
|
unless Zipper::EXTENSIONS.include? File.extname(@path)
|
58
|
-
raise Error::WebDriverError, "expected #{Zipper::EXTENSIONS.join(
|
57
|
+
raise Error::WebDriverError, "expected #{Zipper::EXTENSIONS.join(' or ')}, got #{@path.inspect}"
|
59
58
|
end
|
60
59
|
|
61
60
|
@should_reap_root = true
|
@@ -64,7 +63,7 @@ module Selenium
|
|
64
63
|
end
|
65
64
|
|
66
65
|
def read_id_from_install_rdf(directory)
|
67
|
-
rdf_path = File.join(directory,
|
66
|
+
rdf_path = File.join(directory, 'install.rdf')
|
68
67
|
doc = REXML::Document.new(File.read(rdf_path))
|
69
68
|
namespace = doc.root.namespaces.key(NAMESPACE)
|
70
69
|
|
@@ -78,7 +77,6 @@ module Selenium
|
|
78
77
|
|
79
78
|
raise Error::WebDriverError, "cannot locate extension id in #{rdf_path}"
|
80
79
|
end
|
81
|
-
|
82
80
|
end # Extension
|
83
81
|
end # Firefox
|
84
82
|
end # WebDriver
|
@@ -40,15 +40,6 @@
|
|
40
40
|
"security.csp.enable": false,
|
41
41
|
"security.fileuri.origin_policy": 3,
|
42
42
|
"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
43
|
"signon.rememberSignons": false,
|
53
44
|
"toolkit.networkmanager.disable": true,
|
54
45
|
"toolkit.telemetry.prompted": 2,
|
@@ -64,12 +55,12 @@
|
|
64
55
|
"browser.newtabpage.enabled": false,
|
65
56
|
"browser.startup.page": 0,
|
66
57
|
"browser.startup.homepage": "about:blank",
|
58
|
+
"browser.startup.homepage_override.mstone": "ignore",
|
67
59
|
"browser.usedOnWindows10.introURL": "about:blank",
|
68
60
|
"dom.max_chrome_script_run_time": 30,
|
69
61
|
"dom.max_script_run_time": 30,
|
70
62
|
"dom.report_all_js_exceptions": true,
|
71
63
|
"javascript.options.showInConsole": true,
|
72
|
-
"network.http.max-connections-per-server": 10,
|
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
|
@@ -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,16 +77,16 @@ 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
|
+
@binary.quit
|
88
|
+
error = "unable to obtain stable firefox connection in #{STABLE_CONNECTION_TIMEOUT} seconds (#{@host}:#{@port})"
|
89
|
+
raise Error::WebDriverError, error
|
92
90
|
end
|
93
91
|
|
94
92
|
def fetch_profile
|
@@ -104,13 +102,12 @@ module Selenium
|
|
104
102
|
end
|
105
103
|
|
106
104
|
def assert_profile
|
107
|
-
raise Error::WebDriverError,
|
105
|
+
raise Error::WebDriverError, 'must create_profile first' unless @profile && @profile_dir
|
108
106
|
end
|
109
107
|
|
110
108
|
def socket_lock
|
111
109
|
@socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
|
112
110
|
end
|
113
|
-
|
114
111
|
end # Launcher
|
115
112
|
end # Firefox
|
116
113
|
end # WebDriver
|
@@ -23,15 +23,15 @@ module Selenium
|
|
23
23
|
class Profile
|
24
24
|
include ProfileHelper
|
25
25
|
|
26
|
-
VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String]
|
26
|
+
VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String].freeze
|
27
27
|
WEBDRIVER_EXTENSION_PATH = File.expand_path("#{WebDriver.root}/selenium/webdriver/firefox/extension/webdriver.xpi")
|
28
28
|
WEBDRIVER_PREFS = {
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
}
|
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
|
35
35
|
|
36
36
|
attr_reader :name, :log_file
|
37
37
|
attr_writer :secure_ssl, :native_events, :load_no_focus_lib
|
@@ -78,18 +78,19 @@ module Selenium
|
|
78
78
|
@additional_prefs = {}
|
79
79
|
else
|
80
80
|
# TODO: clean this up
|
81
|
-
@native_events = model_prefs.delete(WEBDRIVER_PREFS[:native_events]) ==
|
82
|
-
@secure_ssl = model_prefs.delete(WEBDRIVER_PREFS[:untrusted_certs]) !=
|
83
|
-
@untrusted_issuer = model_prefs.delete(WEBDRIVER_PREFS[:untrusted_issuer]) ==
|
84
|
-
|
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'
|
85
86
|
@additional_prefs = model_prefs
|
86
87
|
end
|
87
88
|
|
88
|
-
@extensions
|
89
|
+
@extensions = {}
|
89
90
|
end
|
90
91
|
|
91
92
|
def layout_on_disk
|
92
|
-
profile_dir = @model ? create_tmp_copy(@model) : Dir.mktmpdir(
|
93
|
+
profile_dir = @model ? create_tmp_copy(@model) : Dir.mktmpdir('webdriver-profile')
|
93
94
|
FileReaper << profile_dir
|
94
95
|
|
95
96
|
install_extensions(profile_dir)
|
@@ -100,7 +101,6 @@ module Selenium
|
|
100
101
|
profile_dir
|
101
102
|
end
|
102
103
|
|
103
|
-
|
104
104
|
#
|
105
105
|
# Set a preference for this particular profile.
|
106
106
|
#
|
@@ -109,11 +109,11 @@ module Selenium
|
|
109
109
|
#
|
110
110
|
|
111
111
|
def []=(key, value)
|
112
|
-
unless VALID_PREFERENCE_TYPES.any? { |e| value.
|
112
|
+
unless VALID_PREFERENCE_TYPES.any? { |e| value.is_a? e }
|
113
113
|
raise TypeError, "expected one of #{VALID_PREFERENCE_TYPES.inspect}, got #{value.inspect}:#{value.class}"
|
114
114
|
end
|
115
115
|
|
116
|
-
if value.
|
116
|
+
if value.is_a?(String) && Util.stringified?(value)
|
117
117
|
raise ArgumentError, "preference values must be plain strings: #{key.inspect} => #{value.inspect}"
|
118
118
|
end
|
119
119
|
|
@@ -130,9 +130,8 @@ module Selenium
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def add_webdriver_extension
|
133
|
-
|
134
|
-
|
135
|
-
end
|
133
|
+
return if @extensions.key?(:webdriver)
|
134
|
+
add_extension(WEBDRIVER_EXTENSION_PATH, :webdriver)
|
136
135
|
end
|
137
136
|
|
138
137
|
#
|
@@ -164,7 +163,7 @@ module Selenium
|
|
164
163
|
end
|
165
164
|
|
166
165
|
def proxy=(proxy)
|
167
|
-
unless proxy.
|
166
|
+
unless proxy.is_a? Proxy
|
168
167
|
raise TypeError, "expected #{Proxy.name}, got #{proxy.inspect}:#{proxy.class}"
|
169
168
|
end
|
170
169
|
|
@@ -172,16 +171,16 @@ module Selenium
|
|
172
171
|
when :manual
|
173
172
|
self['network.proxy.type'] = 1
|
174
173
|
|
175
|
-
set_manual_proxy_preference
|
176
|
-
set_manual_proxy_preference
|
177
|
-
set_manual_proxy_preference
|
178
|
-
set_manual_proxy_preference
|
174
|
+
set_manual_proxy_preference 'ftp', proxy.ftp
|
175
|
+
set_manual_proxy_preference 'http', proxy.http
|
176
|
+
set_manual_proxy_preference 'ssl', proxy.ssl
|
177
|
+
set_manual_proxy_preference 'socks', proxy.socks
|
179
178
|
|
180
|
-
if proxy.no_proxy
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
179
|
+
self['network.proxy.no_proxies_on'] = if proxy.no_proxy
|
180
|
+
proxy.no_proxy
|
181
|
+
else
|
182
|
+
''
|
183
|
+
end
|
185
184
|
when :pac
|
186
185
|
self['network.proxy.type'] = 2
|
187
186
|
self['network.proxy.autoconfig_url'] = proxy.pac
|
@@ -199,17 +198,17 @@ module Selenium
|
|
199
198
|
def set_manual_proxy_preference(key, value)
|
200
199
|
return unless value
|
201
200
|
|
202
|
-
host, port = value.to_s.split(
|
201
|
+
host, port = value.to_s.split(':', 2)
|
203
202
|
|
204
203
|
self["network.proxy.#{key}"] = host
|
205
204
|
self["network.proxy.#{key}_port"] = Integer(port) if port
|
206
205
|
end
|
207
206
|
|
208
207
|
def install_extensions(directory)
|
209
|
-
destination = File.join(directory,
|
208
|
+
destination = File.join(directory, 'extensions')
|
210
209
|
|
211
210
|
@extensions.each do |name, extension|
|
212
|
-
p :
|
211
|
+
p extension: name if $DEBUG
|
213
212
|
extension.write_to(destination)
|
214
213
|
end
|
215
214
|
end
|
@@ -221,7 +220,7 @@ module Selenium
|
|
221
220
|
end
|
222
221
|
|
223
222
|
def delete_extensions_cache(directory)
|
224
|
-
FileUtils.rm_f File.join(directory,
|
223
|
+
FileUtils.rm_f File.join(directory, 'extensions.cache')
|
225
224
|
end
|
226
225
|
|
227
226
|
def delete_lock_files(directory)
|
@@ -247,7 +246,7 @@ module Selenium
|
|
247
246
|
prefs[WEBDRIVER_PREFS[:untrusted_issuer]] = assume_untrusted_certificate_issuer?
|
248
247
|
|
249
248
|
# If the user sets the home page, we should also start up there
|
250
|
-
prefs[
|
249
|
+
prefs['startup.homepage_welcome_url'] = prefs['browser.startup.homepage']
|
251
250
|
|
252
251
|
write_prefs prefs, path
|
253
252
|
end
|
@@ -257,25 +256,24 @@ module Selenium
|
|
257
256
|
return prefs unless File.exist?(path)
|
258
257
|
|
259
258
|
File.read(path).split("\n").each do |line|
|
260
|
-
|
261
|
-
|
259
|
+
next unless line =~ /user_pref\("([^"]+)"\s*,\s*(.+?)\);/
|
260
|
+
key = Regexp.last_match(1).strip
|
261
|
+
value = Regexp.last_match(2).strip
|
262
262
|
|
263
|
-
|
264
|
-
|
265
|
-
end
|
263
|
+
# wrap the value in an array to make it a valid JSON string.
|
264
|
+
prefs[key] = JSON.parse("[#{value}]").first
|
266
265
|
end
|
267
266
|
|
268
267
|
prefs
|
269
268
|
end
|
270
269
|
|
271
270
|
def write_prefs(prefs, path)
|
272
|
-
File.open(path,
|
271
|
+
File.open(path, 'w') do |file|
|
273
272
|
prefs.each do |key, value|
|
274
273
|
file.puts %{user_pref("#{key}", #{value.to_json});}
|
275
274
|
end
|
276
|
-
|
275
|
+
end
|
277
276
|
end
|
278
|
-
|
279
277
|
end # Profile
|
280
278
|
end # Firefox
|
281
279
|
end # WebDriver
|