selenium-webdriver 2.53.3 → 3.142.7
Sign up to get free protection for your applications and to get access to all the features.
- 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,7 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
class Navigation
|
23
|
-
|
24
23
|
def initialize(bridge)
|
25
24
|
@bridge = bridge
|
26
25
|
end
|
@@ -38,7 +37,7 @@ module Selenium
|
|
38
37
|
#
|
39
38
|
|
40
39
|
def back
|
41
|
-
@bridge.
|
40
|
+
@bridge.go_back
|
42
41
|
end
|
43
42
|
|
44
43
|
#
|
@@ -46,7 +45,7 @@ module Selenium
|
|
46
45
|
#
|
47
46
|
|
48
47
|
def forward
|
49
|
-
@bridge.
|
48
|
+
@bridge.go_forward
|
50
49
|
end
|
51
50
|
|
52
51
|
#
|
@@ -56,7 +55,6 @@ module Selenium
|
|
56
55
|
def refresh
|
57
56
|
@bridge.refresh
|
58
57
|
end
|
59
|
-
|
60
58
|
end # Navigation
|
61
59
|
end # WebDriver
|
62
60
|
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
|
@@ -19,136 +19,35 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# @option opts [String] :path ('/') A path
|
39
|
-
# @option opts [String] :secure (false) A boolean
|
40
|
-
# @option opts [Time,DateTime,Numeric,nil] :expires (nil) Expiry date, either as a Time, DateTime, or seconds since epoch.
|
41
|
-
#
|
42
|
-
# @raise [ArgumentError] if :name or :value is not specified
|
43
|
-
#
|
44
|
-
|
45
|
-
def add_cookie(opts = {})
|
46
|
-
raise ArgumentError, "name is required" unless opts[:name]
|
47
|
-
raise ArgumentError, "value is required" unless opts[:value]
|
48
|
-
|
49
|
-
opts[:path] ||= "/"
|
50
|
-
opts[:secure] ||= false
|
51
|
-
|
52
|
-
if obj = opts.delete(:expires)
|
53
|
-
opts[:expiry] = seconds_from(obj).to_i
|
22
|
+
module Common
|
23
|
+
class Options
|
24
|
+
private
|
25
|
+
|
26
|
+
def generate_as_json(value)
|
27
|
+
if value.respond_to?(:as_json)
|
28
|
+
value.as_json
|
29
|
+
elsif value.is_a?(Hash)
|
30
|
+
value.each_with_object({}) { |(key, val), hash| hash[convert_json_key(key)] = generate_as_json(val) }
|
31
|
+
elsif value.is_a?(Array)
|
32
|
+
value.map(&method(:generate_as_json))
|
33
|
+
elsif value.is_a?(Symbol)
|
34
|
+
value.to_s
|
35
|
+
else
|
36
|
+
value
|
37
|
+
end
|
54
38
|
end
|
55
39
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
#
|
60
|
-
# Get the cookie with the given name
|
61
|
-
#
|
62
|
-
# @param [String] name the name of the cookie
|
63
|
-
# @return [Hash, nil] the cookie, or nil if it wasn't found.
|
64
|
-
#
|
65
|
-
|
66
|
-
def cookie_named(name)
|
67
|
-
all_cookies.find { |c| c[:name] == name }
|
68
|
-
end
|
69
|
-
|
70
|
-
#
|
71
|
-
# Delete the cookie with the given name
|
72
|
-
#
|
73
|
-
# @param [String] name the name of the cookie to delete
|
74
|
-
#
|
75
|
-
|
76
|
-
def delete_cookie(name)
|
77
|
-
@bridge.deleteCookie name
|
78
|
-
end
|
79
|
-
|
80
|
-
#
|
81
|
-
# Delete all cookies
|
82
|
-
#
|
40
|
+
def convert_json_key(key)
|
41
|
+
key = camel_case(key) if key.is_a?(Symbol)
|
42
|
+
return key if key.is_a?(String)
|
83
43
|
|
84
|
-
|
85
|
-
@bridge.deleteAllCookies
|
86
|
-
end
|
87
|
-
|
88
|
-
#
|
89
|
-
# Get all cookies
|
90
|
-
#
|
91
|
-
# @return [Array<Hash>] list of cookies
|
92
|
-
#
|
93
|
-
|
94
|
-
def all_cookies
|
95
|
-
@bridge.getAllCookies.map do |cookie|
|
96
|
-
{
|
97
|
-
:name => cookie["name"],
|
98
|
-
:value => cookie["value"],
|
99
|
-
:path => cookie["path"],
|
100
|
-
:domain => cookie["domain"] && strip_port(cookie["domain"]),
|
101
|
-
:expires => cookie["expiry"] && datetime_at(cookie['expiry']),
|
102
|
-
:secure => cookie["secure"]
|
103
|
-
}
|
44
|
+
raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class}"
|
104
45
|
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def timeouts
|
108
|
-
@timeouts ||= Timeouts.new(@bridge)
|
109
|
-
end
|
110
|
-
|
111
|
-
#
|
112
|
-
# @api beta This API may be changed or removed in a future release.
|
113
|
-
#
|
114
|
-
|
115
|
-
def logs
|
116
|
-
@logs ||= Logs.new(@bridge)
|
117
|
-
end
|
118
|
-
|
119
|
-
#
|
120
|
-
# @api beta This API may be changed or removed in a future release.
|
121
|
-
#
|
122
46
|
|
123
|
-
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
private
|
128
|
-
|
129
|
-
SECONDS_PER_DAY = 86_400.0
|
130
|
-
|
131
|
-
def datetime_at(int)
|
132
|
-
DateTime.civil(1970) + (int / SECONDS_PER_DAY)
|
133
|
-
end
|
134
|
-
|
135
|
-
def seconds_from(obj)
|
136
|
-
case obj
|
137
|
-
when Time
|
138
|
-
obj.to_f
|
139
|
-
when DateTime
|
140
|
-
(obj - DateTime.civil(1970)) * SECONDS_PER_DAY
|
141
|
-
when Numeric
|
142
|
-
obj
|
143
|
-
else
|
144
|
-
raise ArgumentError, "invalid value for expiration date: #{obj.inspect}"
|
47
|
+
def camel_case(str)
|
48
|
+
str.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
145
49
|
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def strip_port(str)
|
149
|
-
str.split(":", 2).first
|
150
|
-
end
|
151
|
-
|
152
|
-
end # Options
|
50
|
+
end # Options
|
51
|
+
end # Common
|
153
52
|
end # WebDriver
|
154
53
|
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
|
@@ -22,43 +22,32 @@ require 'socket'
|
|
22
22
|
|
23
23
|
module Selenium
|
24
24
|
module WebDriver
|
25
|
-
|
26
25
|
# @api private
|
27
26
|
module Platform
|
28
|
-
|
29
27
|
module_function
|
30
28
|
|
31
29
|
def home
|
32
|
-
|
33
|
-
@home ||= jruby? ? ENV_JAVA['user.home'] : ENV['HOME']
|
30
|
+
@home ||= Dir.home
|
34
31
|
end
|
35
32
|
|
36
33
|
def engine
|
37
|
-
@engine ||=
|
38
|
-
if defined? RUBY_ENGINE
|
39
|
-
RUBY_ENGINE.to_sym
|
40
|
-
else
|
41
|
-
:ruby
|
42
|
-
end
|
43
|
-
)
|
34
|
+
@engine ||= RUBY_ENGINE.to_sym
|
44
35
|
end
|
45
36
|
|
46
37
|
def os
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
)
|
38
|
+
host_os = RbConfig::CONFIG['host_os']
|
39
|
+
@os ||= case host_os
|
40
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
41
|
+
:windows
|
42
|
+
when /darwin|mac os/
|
43
|
+
:macosx
|
44
|
+
when /linux/
|
45
|
+
:linux
|
46
|
+
when /solaris|bsd/
|
47
|
+
:unix
|
48
|
+
else
|
49
|
+
raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
|
50
|
+
end
|
62
51
|
end
|
63
52
|
|
64
53
|
def ci
|
@@ -66,37 +55,29 @@ module Selenium
|
|
66
55
|
:travis
|
67
56
|
elsif ENV['JENKINS']
|
68
57
|
:jenkins
|
58
|
+
elsif ENV['APPVEYOR']
|
59
|
+
:appveyor
|
69
60
|
end
|
70
61
|
end
|
71
62
|
|
72
63
|
def bitsize
|
73
|
-
@bitsize ||= (
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
)
|
64
|
+
@bitsize ||= if defined?(FFI::Platform::ADDRESS_SIZE)
|
65
|
+
FFI::Platform::ADDRESS_SIZE
|
66
|
+
elsif defined?(FFI)
|
67
|
+
FFI.type_size(:pointer) == 4 ? 32 : 64
|
68
|
+
elsif jruby?
|
69
|
+
Integer(ENV_JAVA['sun.arch.data.model'])
|
70
|
+
else
|
71
|
+
1.size == 4 ? 32 : 64
|
72
|
+
end
|
84
73
|
end
|
85
74
|
|
86
75
|
def jruby?
|
87
76
|
engine == :jruby
|
88
77
|
end
|
89
78
|
|
90
|
-
def
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
def ruby187?
|
95
|
-
!!(RUBY_VERSION =~ /^1\.8\.7/)
|
96
|
-
end
|
97
|
-
|
98
|
-
def ruby19?
|
99
|
-
!!(RUBY_VERSION =~ /^1\.9/)
|
79
|
+
def ruby_version
|
80
|
+
RUBY_VERSION
|
100
81
|
end
|
101
82
|
|
102
83
|
def windows?
|
@@ -111,68 +92,78 @@ module Selenium
|
|
111
92
|
os == :linux
|
112
93
|
end
|
113
94
|
|
95
|
+
def wsl?
|
96
|
+
return false unless linux?
|
97
|
+
|
98
|
+
File.read('/proc/version').include?('Microsoft')
|
99
|
+
end
|
100
|
+
|
114
101
|
def cygwin?
|
115
|
-
|
102
|
+
RUBY_PLATFORM =~ /cygwin/
|
103
|
+
!Regexp.last_match.nil?
|
116
104
|
end
|
117
105
|
|
118
106
|
def null_device
|
119
|
-
|
120
|
-
if defined?(File::NULL)
|
121
|
-
File::NULL
|
122
|
-
else
|
123
|
-
Platform.windows? ? 'NUL' : '/dev/null'
|
124
|
-
end
|
125
|
-
)
|
107
|
+
File::NULL
|
126
108
|
end
|
127
109
|
|
128
110
|
def wrap_in_quotes_if_necessary(str)
|
129
|
-
windows? && !cygwin? ? %
|
111
|
+
windows? && !cygwin? ? %("#{str}") : str
|
130
112
|
end
|
131
113
|
|
132
|
-
def cygwin_path(path, opts
|
114
|
+
def cygwin_path(path, **opts)
|
133
115
|
flags = []
|
134
|
-
opts.each { |k,v| flags << "--#{k}" if v }
|
116
|
+
opts.each { |k, v| flags << "--#{k}" if v }
|
135
117
|
|
136
118
|
`cygpath #{flags.join ' '} "#{path}"`.strip
|
137
119
|
end
|
138
120
|
|
121
|
+
def unix_path(path)
|
122
|
+
path.tr(File::ALT_SEPARATOR, File::SEPARATOR)
|
123
|
+
end
|
124
|
+
|
125
|
+
def windows_path(path)
|
126
|
+
path.tr(File::SEPARATOR, File::ALT_SEPARATOR)
|
127
|
+
end
|
128
|
+
|
139
129
|
def make_writable(file)
|
140
|
-
File.chmod
|
130
|
+
File.chmod 0o766, file
|
141
131
|
end
|
142
132
|
|
143
133
|
def assert_file(path)
|
144
|
-
|
145
|
-
|
146
|
-
|
134
|
+
return if File.file? path
|
135
|
+
|
136
|
+
raise Error::WebDriverError, "not a file: #{path.inspect}"
|
147
137
|
end
|
148
138
|
|
149
139
|
def assert_executable(path)
|
150
140
|
assert_file(path)
|
151
141
|
|
152
|
-
|
153
|
-
|
154
|
-
|
142
|
+
return if File.executable? path
|
143
|
+
|
144
|
+
raise Error::WebDriverError, "not executable: #{path.inspect}"
|
155
145
|
end
|
156
146
|
|
157
|
-
def exit_hook
|
147
|
+
def exit_hook
|
158
148
|
pid = Process.pid
|
159
149
|
|
160
|
-
at_exit
|
161
|
-
yield if Process.pid == pid
|
162
|
-
end
|
150
|
+
at_exit { yield if Process.pid == pid }
|
163
151
|
end
|
164
152
|
|
165
153
|
def find_binary(*binary_names)
|
166
154
|
paths = ENV['PATH'].split(File::PATH_SEPARATOR)
|
167
|
-
|
155
|
+
|
156
|
+
if windows?
|
157
|
+
binary_names.map! { |n| "#{n}.exe" }
|
158
|
+
binary_names.dup.each { |n| binary_names << n.gsub('exe', 'bat') }
|
159
|
+
end
|
168
160
|
|
169
161
|
binary_names.each do |binary_name|
|
170
162
|
paths.each do |path|
|
171
163
|
full_path = File.join(path, binary_name)
|
172
|
-
full_path
|
173
|
-
exe = Dir.glob(full_path).
|
174
|
-
|
175
|
-
return exe if File.executable?(exe)
|
164
|
+
full_path = unix_path(full_path) if windows?
|
165
|
+
exe = Dir.glob(full_path).find { |f| File.executable?(f) }
|
166
|
+
return exe if exe
|
176
167
|
end
|
177
168
|
end
|
178
169
|
|
@@ -181,8 +172,9 @@ module Selenium
|
|
181
172
|
|
182
173
|
def find_in_program_files(*binary_names)
|
183
174
|
paths = [
|
184
|
-
ENV['PROGRAMFILES'] ||
|
185
|
-
ENV['ProgramFiles(x86)'] ||
|
175
|
+
ENV['PROGRAMFILES'] || '\\Program Files',
|
176
|
+
ENV['ProgramFiles(x86)'] || '\\Program Files (x86)',
|
177
|
+
ENV['ProgramW6432'] || '\\Program Files'
|
186
178
|
]
|
187
179
|
|
188
180
|
paths.each do |root|
|
@@ -196,13 +188,11 @@ module Selenium
|
|
196
188
|
end
|
197
189
|
|
198
190
|
def localhost
|
199
|
-
info = Socket.getaddrinfo
|
191
|
+
info = Socket.getaddrinfo 'localhost', 80, Socket::AF_INET, Socket::SOCK_STREAM
|
200
192
|
|
201
|
-
|
202
|
-
raise Error::WebDriverError, "unable to translate 'localhost' for TCP + IPv4"
|
203
|
-
end
|
193
|
+
return info[0][3] unless info.empty?
|
204
194
|
|
205
|
-
|
195
|
+
raise Error::WebDriverError, "unable to translate 'localhost' for TCP + IPv4"
|
206
196
|
end
|
207
197
|
|
208
198
|
def ip
|
@@ -222,27 +212,11 @@ module Selenium
|
|
222
212
|
end
|
223
213
|
|
224
214
|
def interfaces
|
225
|
-
interfaces = Socket.getaddrinfo(
|
226
|
-
interfaces += [
|
215
|
+
interfaces = Socket.getaddrinfo('localhost', 8080).map { |e| e[3] }
|
216
|
+
interfaces += ['0.0.0.0', Platform.ip]
|
227
217
|
|
228
218
|
interfaces.compact.uniq
|
229
219
|
end
|
230
|
-
|
231
220
|
end # Platform
|
232
221
|
end # WebDriver
|
233
222
|
end # Selenium
|
234
|
-
|
235
|
-
if __FILE__ == $0
|
236
|
-
p :engine => Selenium::WebDriver::Platform.engine,
|
237
|
-
:os => Selenium::WebDriver::Platform.os,
|
238
|
-
:ruby187? => Selenium::WebDriver::Platform.ruby187?,
|
239
|
-
:ruby19? => Selenium::WebDriver::Platform.ruby19?,
|
240
|
-
:jruby? => Selenium::WebDriver::Platform.jruby?,
|
241
|
-
:windows? => Selenium::WebDriver::Platform.windows?,
|
242
|
-
:home => Selenium::WebDriver::Platform.home,
|
243
|
-
:bitsize => Selenium::WebDriver::Platform.bitsize,
|
244
|
-
:localhost => Selenium::WebDriver::Platform.localhost,
|
245
|
-
:ip => Selenium::WebDriver::Platform.ip,
|
246
|
-
:interfaces => Selenium::WebDriver::Platform.interfaces,
|
247
|
-
:null_device => Selenium::WebDriver::Platform.null_device
|
248
|
-
end
|
@@ -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,28 +25,17 @@ module Selenium
|
|
25
25
|
port
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# (b) should pick a random port outside the ephemeral port range
|
33
|
-
#
|
34
|
-
server = TCPServer.new(Platform.localhost, 0)
|
35
|
-
port = server.addr[1]
|
36
|
-
server.close
|
37
|
-
|
38
|
-
port
|
39
|
-
end
|
40
|
-
|
41
|
-
IGNORED_ERRORS = [Errno::EADDRNOTAVAIL]
|
42
|
-
IGNORED_ERRORS << Errno::EBADF if Platform.cygwin?
|
28
|
+
IGNORED_ERRORS = [Errno::EADDRNOTAVAIL, Errno::EAFNOSUPPORT].tap { |arr|
|
29
|
+
arr << Errno::EBADF if Platform.cygwin?
|
30
|
+
arr << Errno::EACCES if Platform.windows?
|
31
|
+
}.freeze
|
43
32
|
|
44
33
|
def self.free?(port)
|
45
34
|
Platform.interfaces.each do |host|
|
46
35
|
begin
|
47
36
|
TCPServer.new(host, port).close
|
48
37
|
rescue *IGNORED_ERRORS => ex
|
49
|
-
|
38
|
+
WebDriver.logger.debug("port prober could not bind to #{host}:#{port} (#{ex.message})")
|
50
39
|
# ignored - some machines appear unable to bind to some of their interfaces
|
51
40
|
end
|
52
41
|
end
|
@@ -55,7 +44,6 @@ module Selenium
|
|
55
44
|
rescue SocketError, Errno::EADDRINUSE
|
56
45
|
false
|
57
46
|
end
|
58
|
-
|
59
47
|
end # PortProber
|
60
48
|
end # WebDriver
|
61
49
|
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
|
@@ -19,7 +19,6 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
|
23
22
|
#
|
24
23
|
# @api private
|
25
24
|
#
|
@@ -28,27 +27,26 @@ module Selenium
|
|
28
27
|
#
|
29
28
|
|
30
29
|
module ProfileHelper
|
31
|
-
|
32
30
|
def self.included(base)
|
33
31
|
base.extend ClassMethods
|
34
32
|
end
|
35
33
|
|
36
|
-
def as_json(
|
37
|
-
{
|
34
|
+
def as_json(*)
|
35
|
+
{"zip" => Zipper.zip(layout_on_disk)}
|
38
36
|
end
|
39
37
|
|
40
|
-
def to_json(*
|
38
|
+
def to_json(*)
|
41
39
|
JSON.generate as_json
|
42
40
|
end
|
43
41
|
|
44
42
|
private
|
45
43
|
|
46
44
|
def create_tmp_copy(directory)
|
47
|
-
tmp_directory = Dir.mktmpdir(
|
45
|
+
tmp_directory = Dir.mktmpdir('webdriver-rb-profilecopy')
|
48
46
|
|
49
47
|
# TODO: must be a better way..
|
50
48
|
FileUtils.rm_rf tmp_directory
|
51
|
-
FileUtils.mkdir_p File.dirname(tmp_directory), :
|
49
|
+
FileUtils.mkdir_p File.dirname(tmp_directory), mode: 0o700
|
52
50
|
FileUtils.cp_r directory, tmp_directory
|
53
51
|
|
54
52
|
tmp_directory
|
@@ -72,7 +70,7 @@ module Selenium
|
|
72
70
|
tmp_dir = Dir.mktmpdir
|
73
71
|
begin
|
74
72
|
zip_path = File.join(tmp_dir, "webdriver-profile-duplicate-#{json.hash}.zip")
|
75
|
-
File.open(zip_path,
|
73
|
+
File.open(zip_path, 'wb') { |zip_file| zip_file << Base64.decode64(data) }
|
76
74
|
|
77
75
|
new Zipper.unzip(zip_path)
|
78
76
|
ensure
|
@@ -80,7 +78,6 @@ module Selenium
|
|
80
78
|
end
|
81
79
|
end
|
82
80
|
end # ClassMethods
|
83
|
-
|
84
81
|
end # ProfileHelper
|
85
82
|
end # WebDriver
|
86
83
|
end # Selenium
|