selenium-webdriver 3.141.0 → 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 +4 -4
- data/CHANGES +150 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/lib/selenium/server.rb +9 -7
- data/lib/selenium/webdriver/atoms/getAttribute.js +6 -7
- data/lib/selenium/webdriver/atoms/isDisplayed.js +60 -59
- data/lib/selenium/webdriver/atoms.rb +20 -1
- data/lib/selenium/webdriver/chrome/bridge.rb +23 -3
- data/lib/selenium/webdriver/chrome/driver.rb +30 -20
- data/lib/selenium/webdriver/chrome/options.rb +11 -7
- data/lib/selenium/webdriver/chrome/profile.rb +6 -5
- data/lib/selenium/webdriver/chrome/service.rb +13 -13
- data/lib/selenium/webdriver/chrome.rb +10 -4
- data/lib/selenium/webdriver/common/action_builder.rb +2 -0
- data/lib/selenium/webdriver/common/alert.rb +2 -0
- data/lib/selenium/webdriver/common/bridge_helper.rb +8 -5
- data/lib/selenium/webdriver/common/driver.rb +22 -7
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +3 -3
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +3 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +3 -1
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -0
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -3
- data/lib/selenium/webdriver/common/element.rb +3 -1
- data/lib/selenium/webdriver/common/error.rb +74 -18
- data/lib/selenium/webdriver/common/file_reaper.rb +3 -3
- data/lib/selenium/webdriver/common/html5/local_storage.rb +2 -0
- data/lib/selenium/webdriver/common/html5/session_storage.rb +2 -0
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +4 -1
- data/lib/selenium/webdriver/common/interactions/input_device.rb +3 -0
- data/lib/selenium/webdriver/common/interactions/interaction.rb +3 -0
- data/lib/selenium/webdriver/common/interactions/interactions.rb +3 -1
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +2 -0
- data/lib/selenium/webdriver/common/interactions/key_input.rb +4 -0
- data/lib/selenium/webdriver/common/interactions/none_input.rb +3 -0
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +2 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +7 -0
- data/lib/selenium/webdriver/common/keyboard.rb +4 -1
- data/lib/selenium/webdriver/common/keys.rb +3 -0
- data/lib/selenium/webdriver/common/log_entry.rb +4 -2
- data/lib/selenium/webdriver/common/logger.rb +15 -40
- data/lib/selenium/webdriver/common/logs.rb +2 -0
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/mouse.rb +3 -0
- data/lib/selenium/webdriver/common/navigation.rb +2 -0
- data/lib/selenium/webdriver/common/options.rb +28 -126
- data/lib/selenium/webdriver/common/platform.rb +26 -30
- data/lib/selenium/webdriver/common/port_prober.rb +6 -19
- data/lib/selenium/webdriver/common/profile_helper.rb +2 -0
- data/lib/selenium/webdriver/common/proxy.rb +13 -5
- data/lib/selenium/webdriver/common/search_context.rb +6 -8
- data/lib/selenium/webdriver/common/service.rb +87 -29
- data/lib/selenium/webdriver/common/socket_lock.rb +10 -3
- data/lib/selenium/webdriver/common/socket_poller.rb +26 -18
- data/lib/selenium/webdriver/common/target_locator.rb +6 -4
- data/lib/selenium/webdriver/common/timeouts.rb +2 -0
- data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -6
- data/lib/selenium/webdriver/common/touch_screen.rb +4 -1
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +3 -0
- data/lib/selenium/webdriver/common/{w3c_options.rb → w3c_manager.rb} +3 -1
- data/lib/selenium/webdriver/common/wait.rb +13 -5
- data/lib/selenium/webdriver/common/window.rb +2 -0
- data/lib/selenium/webdriver/common/zipper.rb +3 -3
- data/lib/selenium/webdriver/common.rb +5 -2
- data/lib/selenium/webdriver/edge/bridge.rb +2 -0
- data/lib/selenium/webdriver/edge/driver.rb +6 -13
- data/lib/selenium/webdriver/edge/options.rb +3 -0
- data/lib/selenium/webdriver/edge/service.rb +8 -12
- data/lib/selenium/webdriver/edge.rb +11 -5
- data/lib/selenium/webdriver/firefox/binary.rb +9 -8
- data/lib/selenium/webdriver/firefox/driver.rb +2 -0
- data/lib/selenium/webdriver/firefox/extension.rb +4 -4
- data/lib/selenium/webdriver/firefox/launcher.rb +3 -0
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +7 -3
- data/lib/selenium/webdriver/firefox/marionette/bridge.rb +4 -2
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +6 -12
- data/lib/selenium/webdriver/firefox/options.rb +22 -9
- data/lib/selenium/webdriver/firefox/profile.rb +7 -8
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +3 -0
- data/lib/selenium/webdriver/firefox/service.rb +8 -19
- data/lib/selenium/webdriver/firefox/util.rb +2 -0
- data/lib/selenium/webdriver/firefox.rb +10 -4
- data/lib/selenium/webdriver/ie/driver.rb +5 -11
- data/lib/selenium/webdriver/ie/options.rb +6 -4
- data/lib/selenium/webdriver/ie/service.rb +8 -12
- data/lib/selenium/webdriver/ie.rb +10 -4
- data/lib/selenium/webdriver/remote/bridge.rb +8 -6
- data/lib/selenium/webdriver/remote/capabilities.rb +23 -10
- data/lib/selenium/webdriver/remote/driver.rb +2 -0
- data/lib/selenium/webdriver/remote/http/common.rb +11 -4
- data/lib/selenium/webdriver/remote/http/curb.rb +4 -2
- data/lib/selenium/webdriver/remote/http/default.rb +31 -25
- data/lib/selenium/webdriver/remote/http/persistent.rb +3 -1
- data/lib/selenium/webdriver/remote/oss/bridge.rb +5 -2
- data/lib/selenium/webdriver/remote/oss/commands.rb +106 -104
- data/lib/selenium/webdriver/remote/response.rb +11 -3
- data/lib/selenium/webdriver/remote/server_error.rb +2 -0
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +28 -13
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +37 -21
- data/lib/selenium/webdriver/remote/w3c/commands.rb +61 -58
- data/lib/selenium/webdriver/remote.rb +2 -0
- data/lib/selenium/webdriver/safari/bridge.rb +5 -3
- data/lib/selenium/webdriver/safari/driver.rb +9 -11
- data/lib/selenium/webdriver/safari/options.rb +2 -0
- data/lib/selenium/webdriver/safari/service.rb +6 -25
- data/lib/selenium/webdriver/safari.rb +11 -4
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +2 -0
- data/lib/selenium/webdriver/support/block_event_listener.rb +3 -1
- data/lib/selenium/webdriver/support/color.rb +11 -9
- data/lib/selenium/webdriver/support/escaper.rb +2 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +3 -1
- data/lib/selenium/webdriver/support/select.rb +19 -18
- data/lib/selenium/webdriver/support.rb +2 -0
- data/lib/selenium/webdriver/version.rb +3 -1
- data/lib/selenium/webdriver.rb +3 -1
- data/lib/selenium-webdriver.rb +2 -0
- data/selenium-webdriver.gemspec +15 -8
- metadata +86 -27
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
4
|
# or more contributor license agreements. See the NOTICE file
|
|
3
5
|
# distributed with this work for additional information
|
|
@@ -34,6 +36,7 @@ module Selenium
|
|
|
34
36
|
|
|
35
37
|
def encode
|
|
36
38
|
return nil if no_actions?
|
|
39
|
+
|
|
37
40
|
output = {type: type, id: name, actions: @actions.map(&:encode)}
|
|
38
41
|
output[:parameters] = {pointerType: kind}
|
|
39
42
|
output
|
|
@@ -41,6 +44,7 @@ module Selenium
|
|
|
41
44
|
|
|
42
45
|
def assert_kind(pointer)
|
|
43
46
|
raise TypeError, "#{pointer.inspect} is not a valid pointer type" unless KIND.key? pointer
|
|
47
|
+
|
|
44
48
|
KIND[pointer]
|
|
45
49
|
end
|
|
46
50
|
|
|
@@ -78,14 +82,17 @@ module Selenium
|
|
|
78
82
|
def assert_button(button)
|
|
79
83
|
if button.is_a? Symbol
|
|
80
84
|
raise TypeError, "#{button.inspect} is not a valid button!" unless BUTTONS.key? button
|
|
85
|
+
|
|
81
86
|
button = BUTTONS[button]
|
|
82
87
|
end
|
|
83
88
|
raise ArgumentError, 'Button number cannot be negative!' unless button >= 0
|
|
89
|
+
|
|
84
90
|
button
|
|
85
91
|
end
|
|
86
92
|
|
|
87
93
|
def assert_direction(direction)
|
|
88
94
|
raise TypeError, "#{direction.inspect} is not a valid button direction" unless DIRECTIONS.key? direction
|
|
95
|
+
|
|
89
96
|
DIRECTIONS[direction]
|
|
90
97
|
end
|
|
91
98
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
4
|
# or more contributor license agreements. See the NOTICE file
|
|
3
5
|
# distributed with this work for additional information
|
|
@@ -56,10 +58,11 @@ module Selenium
|
|
|
56
58
|
|
|
57
59
|
private
|
|
58
60
|
|
|
59
|
-
MODIFIERS = [
|
|
61
|
+
MODIFIERS = %i[control shift alt command meta].freeze
|
|
60
62
|
|
|
61
63
|
def assert_modifier(key)
|
|
62
64
|
return if MODIFIERS.include? key
|
|
65
|
+
|
|
63
66
|
raise ArgumentError, "#{key.inspect} is not a modifier key, expected one of #{MODIFIERS.inspect}"
|
|
64
67
|
end
|
|
65
68
|
end # Keyboard
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
4
|
# or more contributor license agreements. See the NOTICE file
|
|
3
5
|
# distributed with this work for additional information
|
|
@@ -110,6 +112,7 @@ module Selenium
|
|
|
110
112
|
|
|
111
113
|
def self.[](key)
|
|
112
114
|
return KEYS[key] if KEYS[key]
|
|
115
|
+
|
|
113
116
|
raise Error::UnsupportedOperationError, "no such key #{key.inspect}"
|
|
114
117
|
end
|
|
115
118
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
4
|
# or more contributor license agreements. See the NOTICE file
|
|
3
5
|
# distributed with this work for additional information
|
|
@@ -28,9 +30,9 @@ module Selenium
|
|
|
28
30
|
|
|
29
31
|
def as_json(*)
|
|
30
32
|
{
|
|
31
|
-
'level'
|
|
33
|
+
'level' => level,
|
|
32
34
|
'timestamp' => timestamp,
|
|
33
|
-
'message'
|
|
35
|
+
'message' => message
|
|
34
36
|
}
|
|
35
37
|
end
|
|
36
38
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
4
|
# or more contributor license agreements. See the NOTICE file
|
|
3
5
|
# distributed with this work for additional information
|
|
@@ -33,54 +35,27 @@ module Selenium
|
|
|
33
35
|
#
|
|
34
36
|
class Logger
|
|
35
37
|
extend Forwardable
|
|
36
|
-
include ::Logger::Severity
|
|
37
38
|
|
|
38
|
-
def_delegators :@logger,
|
|
39
|
+
def_delegators :@logger,
|
|
40
|
+
:close,
|
|
41
|
+
:debug, :debug?,
|
|
39
42
|
:info, :info?,
|
|
40
43
|
:warn, :warn?,
|
|
41
44
|
:error, :error?,
|
|
42
45
|
:fatal, :fatal?,
|
|
43
|
-
:level
|
|
46
|
+
:level, :level=
|
|
44
47
|
|
|
45
48
|
def initialize
|
|
46
49
|
@logger = create_logger($stdout)
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
def output=(io)
|
|
50
|
-
# `Logger#reopen` was added in Ruby 2.3
|
|
51
|
-
if @logger.respond_to?(:reopen)
|
|
52
|
-
@logger.reopen(io)
|
|
53
|
-
else
|
|
54
|
-
@logger = create_logger(io)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
52
|
#
|
|
59
|
-
#
|
|
60
|
-
# Based on https://github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L250
|
|
53
|
+
# Changes logger output to a new IO.
|
|
61
54
|
#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
else
|
|
67
|
-
case severity.to_s.downcase
|
|
68
|
-
when 'debug'.freeze
|
|
69
|
-
@logger.level = DEBUG
|
|
70
|
-
when 'info'.freeze
|
|
71
|
-
@logger.level = INFO
|
|
72
|
-
when 'warn'.freeze
|
|
73
|
-
@logger.level = WARN
|
|
74
|
-
when 'error'.freeze
|
|
75
|
-
@logger.level = ERROR
|
|
76
|
-
when 'fatal'.freeze
|
|
77
|
-
@logger.level = FATAL
|
|
78
|
-
when 'unknown'.freeze
|
|
79
|
-
@logger.level = UNKNOWN
|
|
80
|
-
else
|
|
81
|
-
raise ArgumentError, "invalid log level: #{severity}"
|
|
82
|
-
end
|
|
83
|
-
end
|
|
55
|
+
# @param [String] io
|
|
56
|
+
#
|
|
57
|
+
def output=(io)
|
|
58
|
+
@logger.reopen(io)
|
|
84
59
|
end
|
|
85
60
|
|
|
86
61
|
#
|
|
@@ -95,7 +70,7 @@ module Selenium
|
|
|
95
70
|
# @api private
|
|
96
71
|
#
|
|
97
72
|
def io
|
|
98
|
-
@logger.instance_variable_get(:@logdev).
|
|
73
|
+
@logger.instance_variable_get(:@logdev).dev
|
|
99
74
|
end
|
|
100
75
|
|
|
101
76
|
#
|
|
@@ -105,7 +80,7 @@ module Selenium
|
|
|
105
80
|
# @param [String, nil] new
|
|
106
81
|
#
|
|
107
82
|
def deprecate(old, new = nil)
|
|
108
|
-
message = "[DEPRECATION] #{old} is deprecated"
|
|
83
|
+
message = +"[DEPRECATION] #{old} is deprecated"
|
|
109
84
|
message << if new
|
|
110
85
|
". Use #{new} instead."
|
|
111
86
|
else
|
|
@@ -130,9 +105,9 @@ module Selenium
|
|
|
130
105
|
|
|
131
106
|
def default_level
|
|
132
107
|
if $DEBUG || ENV.key?('DEBUG')
|
|
133
|
-
|
|
108
|
+
:debug
|
|
134
109
|
else
|
|
135
|
-
|
|
110
|
+
:warn
|
|
136
111
|
end
|
|
137
112
|
end
|
|
138
113
|
end # Logger
|
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
class Manager
|
|
23
|
+
#
|
|
24
|
+
# @api private
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
def initialize(bridge)
|
|
28
|
+
@bridge = bridge
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Add a cookie to the browser
|
|
33
|
+
#
|
|
34
|
+
# @param [Hash] opts the options to create a cookie with.
|
|
35
|
+
# @option opts [String] :name A name
|
|
36
|
+
# @option opts [String] :value A value
|
|
37
|
+
# @option opts [String] :path ('/') A path
|
|
38
|
+
# @option opts [String] :secure (false) A boolean
|
|
39
|
+
# @option opts [Time,DateTime,Numeric,nil] :expires (nil) Expiry date, either as a Time, DateTime, or seconds since epoch.
|
|
40
|
+
#
|
|
41
|
+
# @raise [ArgumentError] if :name or :value is not specified
|
|
42
|
+
#
|
|
43
|
+
|
|
44
|
+
def add_cookie(opts = {})
|
|
45
|
+
raise ArgumentError, 'name is required' unless opts[:name]
|
|
46
|
+
raise ArgumentError, 'value is required' unless opts[:value]
|
|
47
|
+
|
|
48
|
+
opts[:path] ||= '/'
|
|
49
|
+
opts[:secure] ||= false
|
|
50
|
+
|
|
51
|
+
obj = opts.delete(:expires)
|
|
52
|
+
opts[:expiry] = seconds_from(obj).to_i if obj
|
|
53
|
+
|
|
54
|
+
@bridge.add_cookie opts
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#
|
|
58
|
+
# Get the cookie with the given name
|
|
59
|
+
#
|
|
60
|
+
# @param [String] name the name of the cookie
|
|
61
|
+
# @return [Hash, nil] the cookie, or nil if it wasn't found.
|
|
62
|
+
#
|
|
63
|
+
|
|
64
|
+
def cookie_named(name)
|
|
65
|
+
all_cookies.find { |c| c[:name] == name }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
#
|
|
69
|
+
# Delete the cookie with the given name
|
|
70
|
+
#
|
|
71
|
+
# @param [String] name the name of the cookie to delete
|
|
72
|
+
#
|
|
73
|
+
|
|
74
|
+
def delete_cookie(name)
|
|
75
|
+
@bridge.delete_cookie name
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# Delete all cookies
|
|
80
|
+
#
|
|
81
|
+
|
|
82
|
+
def delete_all_cookies
|
|
83
|
+
@bridge.delete_all_cookies
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
#
|
|
87
|
+
# Get all cookies
|
|
88
|
+
#
|
|
89
|
+
# @return [Array<Hash>] list of cookies
|
|
90
|
+
#
|
|
91
|
+
|
|
92
|
+
def all_cookies
|
|
93
|
+
@bridge.cookies.map { |cookie| convert_cookie(cookie) }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def timeouts
|
|
97
|
+
@timeouts ||= Timeouts.new(@bridge)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
#
|
|
101
|
+
# @api beta This API may be changed or removed in a future release.
|
|
102
|
+
#
|
|
103
|
+
|
|
104
|
+
def logs
|
|
105
|
+
@logs ||= Logs.new(@bridge)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
#
|
|
109
|
+
# Create a new top-level browsing context
|
|
110
|
+
# https://w3c.github.io/webdriver/#new-window
|
|
111
|
+
# @param type [Symbol] Supports two values: :tab and :window.
|
|
112
|
+
# Use :tab if you'd like the new window to share an OS-level window
|
|
113
|
+
# with the current browsing context.
|
|
114
|
+
# Use :window otherwise
|
|
115
|
+
# @return [String] The value of the window handle
|
|
116
|
+
#
|
|
117
|
+
def new_window(type = :tab)
|
|
118
|
+
case type
|
|
119
|
+
when :tab, :window
|
|
120
|
+
result = @bridge.new_window(type)
|
|
121
|
+
unless result.key?('handle')
|
|
122
|
+
raise UnknownError, "the driver did not return a handle. " \
|
|
123
|
+
"The returned result: #{result.inspect}"
|
|
124
|
+
end
|
|
125
|
+
result['handle']
|
|
126
|
+
else
|
|
127
|
+
raise ArgumentError, "invalid argument for type. Got: '#{type.inspect}'. " \
|
|
128
|
+
"Try :tab or :window"
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
#
|
|
133
|
+
# @api beta This API may be changed or removed in a future release.
|
|
134
|
+
#
|
|
135
|
+
|
|
136
|
+
def window
|
|
137
|
+
@window ||= Window.new(@bridge)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
private
|
|
141
|
+
|
|
142
|
+
SECONDS_PER_DAY = 86_400.0
|
|
143
|
+
|
|
144
|
+
def datetime_at(int)
|
|
145
|
+
DateTime.civil(1970) + (int / SECONDS_PER_DAY)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def seconds_from(obj)
|
|
149
|
+
case obj
|
|
150
|
+
when Time
|
|
151
|
+
obj.to_f
|
|
152
|
+
when DateTime
|
|
153
|
+
(obj - DateTime.civil(1970)) * SECONDS_PER_DAY
|
|
154
|
+
when Numeric
|
|
155
|
+
obj
|
|
156
|
+
else
|
|
157
|
+
raise ArgumentError, "invalid value for expiration date: #{obj.inspect}"
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def strip_port(str)
|
|
162
|
+
str.split(':', 2).first
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def convert_cookie(cookie)
|
|
166
|
+
{
|
|
167
|
+
name: cookie['name'],
|
|
168
|
+
value: cookie['value'],
|
|
169
|
+
path: cookie['path'],
|
|
170
|
+
domain: cookie['domain'] && strip_port(cookie['domain']),
|
|
171
|
+
expires: cookie['expiry'] && datetime_at(cookie['expiry']),
|
|
172
|
+
secure: cookie['secure']
|
|
173
|
+
}
|
|
174
|
+
end
|
|
175
|
+
end # Options
|
|
176
|
+
end # WebDriver
|
|
177
|
+
end # Selenium
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
4
|
# or more contributor license agreements. See the NOTICE file
|
|
3
5
|
# distributed with this work for additional information
|
|
@@ -79,6 +81,7 @@ module Selenium
|
|
|
79
81
|
|
|
80
82
|
def assert_element(element)
|
|
81
83
|
return if element.is_a? Element
|
|
84
|
+
|
|
82
85
|
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
|
|
83
86
|
end
|
|
84
87
|
end # Mouse
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
4
|
# or more contributor license agreements. See the NOTICE file
|
|
3
5
|
# distributed with this work for additional information
|
|
@@ -17,135 +19,35 @@
|
|
|
17
19
|
|
|
18
20
|
module Selenium
|
|
19
21
|
module WebDriver
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
# @option opts [Time,DateTime,Numeric,nil] :expires (nil) Expiry date, either as a Time, DateTime, or seconds since epoch.
|
|
38
|
-
#
|
|
39
|
-
# @raise [ArgumentError] if :name or :value is not specified
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
def add_cookie(opts = {})
|
|
43
|
-
raise ArgumentError, 'name is required' unless opts[:name]
|
|
44
|
-
raise ArgumentError, 'value is required' unless opts[:value]
|
|
45
|
-
|
|
46
|
-
opts[:path] ||= '/'
|
|
47
|
-
opts[:secure] ||= false
|
|
48
|
-
|
|
49
|
-
obj = opts.delete(:expires)
|
|
50
|
-
opts[:expiry] = seconds_from(obj).to_i if obj
|
|
51
|
-
|
|
52
|
-
@bridge.add_cookie opts
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
#
|
|
56
|
-
# Get the cookie with the given name
|
|
57
|
-
#
|
|
58
|
-
# @param [String] name the name of the cookie
|
|
59
|
-
# @return [Hash, nil] the cookie, or nil if it wasn't found.
|
|
60
|
-
#
|
|
61
|
-
|
|
62
|
-
def cookie_named(name)
|
|
63
|
-
all_cookies.find { |c| c[:name] == name }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
#
|
|
67
|
-
# Delete the cookie with the given name
|
|
68
|
-
#
|
|
69
|
-
# @param [String] name the name of the cookie to delete
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
def delete_cookie(name)
|
|
73
|
-
@bridge.delete_cookie name
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
#
|
|
77
|
-
# Delete all cookies
|
|
78
|
-
#
|
|
79
|
-
|
|
80
|
-
def delete_all_cookies
|
|
81
|
-
@bridge.delete_all_cookies
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
#
|
|
85
|
-
# Get all cookies
|
|
86
|
-
#
|
|
87
|
-
# @return [Array<Hash>] list of cookies
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
def all_cookies
|
|
91
|
-
@bridge.cookies.map { |cookie| convert_cookie(cookie) }
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def timeouts
|
|
95
|
-
@timeouts ||= Timeouts.new(@bridge)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
#
|
|
99
|
-
# @api beta This API may be changed or removed in a future release.
|
|
100
|
-
#
|
|
101
|
-
|
|
102
|
-
def logs
|
|
103
|
-
@logs ||= Logs.new(@bridge)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
#
|
|
107
|
-
# @api beta This API may be changed or removed in a future release.
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
def window
|
|
111
|
-
@window ||= Window.new(@bridge)
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
private
|
|
115
|
-
|
|
116
|
-
SECONDS_PER_DAY = 86_400.0
|
|
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
|
|
38
|
+
end
|
|
117
39
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
40
|
+
def convert_json_key(key)
|
|
41
|
+
key = camel_case(key) if key.is_a?(Symbol)
|
|
42
|
+
return key if key.is_a?(String)
|
|
121
43
|
|
|
122
|
-
|
|
123
|
-
case obj
|
|
124
|
-
when Time
|
|
125
|
-
obj.to_f
|
|
126
|
-
when DateTime
|
|
127
|
-
(obj - DateTime.civil(1970)) * SECONDS_PER_DAY
|
|
128
|
-
when Numeric
|
|
129
|
-
obj
|
|
130
|
-
else
|
|
131
|
-
raise ArgumentError, "invalid value for expiration date: #{obj.inspect}"
|
|
44
|
+
raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class}"
|
|
132
45
|
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def strip_port(str)
|
|
136
|
-
str.split(':', 2).first
|
|
137
|
-
end
|
|
138
46
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
domain: cookie['domain'] && strip_port(cookie['domain']),
|
|
145
|
-
expires: cookie['expiry'] && datetime_at(cookie['expiry']),
|
|
146
|
-
secure: cookie['secure']
|
|
147
|
-
}
|
|
148
|
-
end
|
|
149
|
-
end # Options
|
|
47
|
+
def camel_case(str)
|
|
48
|
+
str.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
|
49
|
+
end
|
|
50
|
+
end # Options
|
|
51
|
+
end # Common
|
|
150
52
|
end # WebDriver
|
|
151
53
|
end # Selenium
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
4
|
# or more contributor license agreements. See the NOTICE file
|
|
3
5
|
# distributed with this work for additional information
|
|
@@ -25,12 +27,11 @@ module Selenium
|
|
|
25
27
|
module_function
|
|
26
28
|
|
|
27
29
|
def home
|
|
28
|
-
|
|
29
|
-
@home ||= jruby? ? ENV_JAVA['user.home'] : ENV['HOME']
|
|
30
|
+
@home ||= Dir.home
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def engine
|
|
33
|
-
@engine ||=
|
|
34
|
+
@engine ||= RUBY_ENGINE.to_sym
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def os
|
|
@@ -50,8 +51,13 @@ module Selenium
|
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
def ci
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
if ENV['TRAVIS']
|
|
55
|
+
:travis
|
|
56
|
+
elsif ENV['JENKINS']
|
|
57
|
+
:jenkins
|
|
58
|
+
elsif ENV['APPVEYOR']
|
|
59
|
+
:appveyor
|
|
60
|
+
end
|
|
55
61
|
end
|
|
56
62
|
|
|
57
63
|
def bitsize
|
|
@@ -70,10 +76,6 @@ module Selenium
|
|
|
70
76
|
engine == :jruby
|
|
71
77
|
end
|
|
72
78
|
|
|
73
|
-
def ironruby?
|
|
74
|
-
engine == :ironruby
|
|
75
|
-
end
|
|
76
|
-
|
|
77
79
|
def ruby_version
|
|
78
80
|
RUBY_VERSION
|
|
79
81
|
end
|
|
@@ -92,6 +94,7 @@ module Selenium
|
|
|
92
94
|
|
|
93
95
|
def wsl?
|
|
94
96
|
return false unless linux?
|
|
97
|
+
|
|
95
98
|
File.read('/proc/version').include?('Microsoft')
|
|
96
99
|
end
|
|
97
100
|
|
|
@@ -101,30 +104,35 @@ module Selenium
|
|
|
101
104
|
end
|
|
102
105
|
|
|
103
106
|
def null_device
|
|
104
|
-
|
|
105
|
-
File::NULL
|
|
106
|
-
else
|
|
107
|
-
Platform.windows? ? 'NUL' : '/dev/null'
|
|
108
|
-
end
|
|
107
|
+
File::NULL
|
|
109
108
|
end
|
|
110
109
|
|
|
111
110
|
def wrap_in_quotes_if_necessary(str)
|
|
112
111
|
windows? && !cygwin? ? %("#{str}") : str
|
|
113
112
|
end
|
|
114
113
|
|
|
115
|
-
def cygwin_path(path, opts
|
|
114
|
+
def cygwin_path(path, **opts)
|
|
116
115
|
flags = []
|
|
117
116
|
opts.each { |k, v| flags << "--#{k}" if v }
|
|
118
117
|
|
|
119
118
|
`cygpath #{flags.join ' '} "#{path}"`.strip
|
|
120
119
|
end
|
|
121
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
|
+
|
|
122
129
|
def make_writable(file)
|
|
123
130
|
File.chmod 0o766, file
|
|
124
131
|
end
|
|
125
132
|
|
|
126
133
|
def assert_file(path)
|
|
127
134
|
return if File.file? path
|
|
135
|
+
|
|
128
136
|
raise Error::WebDriverError, "not a file: #{path.inspect}"
|
|
129
137
|
end
|
|
130
138
|
|
|
@@ -132,6 +140,7 @@ module Selenium
|
|
|
132
140
|
assert_file(path)
|
|
133
141
|
|
|
134
142
|
return if File.executable? path
|
|
143
|
+
|
|
135
144
|
raise Error::WebDriverError, "not executable: #{path.inspect}"
|
|
136
145
|
end
|
|
137
146
|
|
|
@@ -152,7 +161,7 @@ module Selenium
|
|
|
152
161
|
binary_names.each do |binary_name|
|
|
153
162
|
paths.each do |path|
|
|
154
163
|
full_path = File.join(path, binary_name)
|
|
155
|
-
full_path
|
|
164
|
+
full_path = unix_path(full_path) if windows?
|
|
156
165
|
exe = Dir.glob(full_path).find { |f| File.executable?(f) }
|
|
157
166
|
return exe if exe
|
|
158
167
|
end
|
|
@@ -182,6 +191,7 @@ module Selenium
|
|
|
182
191
|
info = Socket.getaddrinfo 'localhost', 80, Socket::AF_INET, Socket::SOCK_STREAM
|
|
183
192
|
|
|
184
193
|
return info[0][3] unless info.empty?
|
|
194
|
+
|
|
185
195
|
raise Error::WebDriverError, "unable to translate 'localhost' for TCP + IPv4"
|
|
186
196
|
end
|
|
187
197
|
|
|
@@ -210,17 +220,3 @@ module Selenium
|
|
|
210
220
|
end # Platform
|
|
211
221
|
end # WebDriver
|
|
212
222
|
end # Selenium
|
|
213
|
-
|
|
214
|
-
if $PROGRAM_NAME == __FILE__
|
|
215
|
-
p engine: Selenium::WebDriver::Platform.engine,
|
|
216
|
-
os: Selenium::WebDriver::Platform.os,
|
|
217
|
-
ruby_version: Selenium::WebDriver::Platform.ruby_version,
|
|
218
|
-
jruby?: Selenium::WebDriver::Platform.jruby?,
|
|
219
|
-
windows?: Selenium::WebDriver::Platform.windows?,
|
|
220
|
-
home: Selenium::WebDriver::Platform.home,
|
|
221
|
-
bitsize: Selenium::WebDriver::Platform.bitsize,
|
|
222
|
-
localhost: Selenium::WebDriver::Platform.localhost,
|
|
223
|
-
ip: Selenium::WebDriver::Platform.ip,
|
|
224
|
-
interfaces: Selenium::WebDriver::Platform.interfaces,
|
|
225
|
-
null_device: Selenium::WebDriver::Platform.null_device
|
|
226
|
-
end
|