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,85 +20,100 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Keys
|
23
|
-
|
24
23
|
#
|
25
24
|
# @see Element#send_keys
|
26
|
-
# @see http://www.google.com.au/search?&q=unicode+pua&
|
25
|
+
# @see http://www.google.com.au/search?&q=unicode+pua&btnK=Search
|
27
26
|
#
|
28
27
|
|
29
28
|
KEYS = {
|
30
|
-
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
62
|
-
:
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
78
|
-
:
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
94
|
-
|
29
|
+
null: "\ue000",
|
30
|
+
cancel: "\ue001",
|
31
|
+
help: "\ue002",
|
32
|
+
backspace: "\ue003",
|
33
|
+
tab: "\ue004",
|
34
|
+
clear: "\ue005",
|
35
|
+
return: "\ue006",
|
36
|
+
enter: "\ue007",
|
37
|
+
shift: "\ue008",
|
38
|
+
left_shift: "\ue008",
|
39
|
+
control: "\ue009",
|
40
|
+
left_control: "\ue009",
|
41
|
+
alt: "\ue00A",
|
42
|
+
left_alt: "\ue00A",
|
43
|
+
pause: "\ue00B",
|
44
|
+
escape: "\ue00C",
|
45
|
+
space: "\ue00D",
|
46
|
+
page_up: "\ue00E",
|
47
|
+
page_down: "\ue00F",
|
48
|
+
end: "\ue010",
|
49
|
+
home: "\ue011",
|
50
|
+
left: "\ue012",
|
51
|
+
arrow_left: "\ue012",
|
52
|
+
up: "\ue013",
|
53
|
+
arrow_up: "\ue013",
|
54
|
+
right: "\ue014",
|
55
|
+
arrow_right: "\ue014",
|
56
|
+
down: "\ue015",
|
57
|
+
arrow_down: "\ue015",
|
58
|
+
insert: "\ue016",
|
59
|
+
delete: "\ue017",
|
60
|
+
semicolon: "\ue018",
|
61
|
+
equals: "\ue019",
|
62
|
+
numpad0: "\ue01A",
|
63
|
+
numpad1: "\ue01B",
|
64
|
+
numpad2: "\ue01C",
|
65
|
+
numpad3: "\ue01D",
|
66
|
+
numpad4: "\ue01E",
|
67
|
+
numpad5: "\ue01F",
|
68
|
+
numpad6: "\ue020",
|
69
|
+
numpad7: "\ue021",
|
70
|
+
numpad8: "\ue022",
|
71
|
+
numpad9: "\ue023",
|
72
|
+
multiply: "\ue024",
|
73
|
+
add: "\ue025",
|
74
|
+
separator: "\ue026",
|
75
|
+
subtract: "\ue027",
|
76
|
+
decimal: "\ue028",
|
77
|
+
divide: "\ue029",
|
78
|
+
f1: "\ue031",
|
79
|
+
f2: "\ue032",
|
80
|
+
f3: "\ue033",
|
81
|
+
f4: "\ue034",
|
82
|
+
f5: "\ue035",
|
83
|
+
f6: "\ue036",
|
84
|
+
f7: "\ue037",
|
85
|
+
f8: "\ue038",
|
86
|
+
f9: "\ue039",
|
87
|
+
f10: "\ue03A",
|
88
|
+
f11: "\ue03B",
|
89
|
+
f12: "\ue03C",
|
90
|
+
meta: "\ue03D",
|
91
|
+
command: "\ue03D", # alias
|
92
|
+
left_meta: "\ue03D", # alias
|
93
|
+
right_shift: "\ue050",
|
94
|
+
right_control: "\ue051",
|
95
|
+
right_alt: "\ue052",
|
96
|
+
right_meta: "\ue053",
|
97
|
+
numpad_page_up: "\ue054",
|
98
|
+
numpad_page_down: "\ue055",
|
99
|
+
numpad_end: "\ue056",
|
100
|
+
numpad_home: "\ue057",
|
101
|
+
numpad_left: "\ue058",
|
102
|
+
numpad_up: "\ue059",
|
103
|
+
numpad_right: "\ue05A",
|
104
|
+
numpad_down: "\ue05B",
|
105
|
+
numpad_insert: "\ue05C",
|
106
|
+
numpad_delete: "\ue05D"
|
107
|
+
}.freeze
|
95
108
|
|
96
109
|
#
|
97
110
|
# @api private
|
98
111
|
#
|
99
112
|
|
100
113
|
def self.[](key)
|
101
|
-
KEYS[key]
|
114
|
+
return KEYS[key] if KEYS[key]
|
115
|
+
|
116
|
+
raise Error::UnsupportedOperationError, "no such key #{key.inspect}"
|
102
117
|
end
|
103
118
|
|
104
119
|
#
|
@@ -106,21 +121,26 @@ module Selenium
|
|
106
121
|
#
|
107
122
|
|
108
123
|
def self.encode(keys)
|
109
|
-
keys.map
|
110
|
-
|
111
|
-
when Symbol
|
112
|
-
Keys[arg]
|
113
|
-
when Array
|
114
|
-
arg = arg.map { |e| e.kind_of?(Symbol) ? Keys[e] : e }.join
|
115
|
-
arg << Keys[:null]
|
124
|
+
keys.map { |key| encode_key(key) }
|
125
|
+
end
|
116
126
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
127
|
+
#
|
128
|
+
# @api private
|
129
|
+
#
|
130
|
+
|
131
|
+
def self.encode_key(key)
|
132
|
+
case key
|
133
|
+
when Symbol
|
134
|
+
Keys[key]
|
135
|
+
when Array
|
136
|
+
key = key.map { |e| e.is_a?(Symbol) ? Keys[e] : e }.join
|
137
|
+
key << Keys[:null]
|
138
|
+
|
139
|
+
key
|
140
|
+
else
|
141
|
+
key.to_s
|
121
142
|
end
|
122
143
|
end
|
123
|
-
|
124
144
|
end # Keys
|
125
145
|
end # WebDriver
|
126
146
|
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,16 +23,16 @@ module Selenium
|
|
23
23
|
attr_reader :level, :timestamp, :message
|
24
24
|
|
25
25
|
def initialize(level, timestamp, message)
|
26
|
-
@level
|
26
|
+
@level = level
|
27
27
|
@timestamp = timestamp
|
28
|
-
@message
|
28
|
+
@message = message
|
29
29
|
end
|
30
30
|
|
31
|
-
def as_json(
|
31
|
+
def as_json(*)
|
32
32
|
{
|
33
|
-
'level'
|
33
|
+
'level' => level,
|
34
34
|
'timestamp' => timestamp,
|
35
|
-
'message'
|
35
|
+
'message' => message
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
@@ -43,7 +43,6 @@ module Selenium
|
|
43
43
|
def time
|
44
44
|
Time.at timestamp / 1000
|
45
45
|
end
|
46
|
-
|
47
46
|
end # LogEntry
|
48
47
|
end # WebDriver
|
49
48
|
end # Selenium
|
@@ -0,0 +1,115 @@
|
|
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
|
+
require 'forwardable'
|
21
|
+
require 'logger'
|
22
|
+
|
23
|
+
module Selenium
|
24
|
+
module WebDriver
|
25
|
+
#
|
26
|
+
# @example Enable full logging
|
27
|
+
# Selenium::WebDriver.logger.level = :debug
|
28
|
+
#
|
29
|
+
# @example Log to file
|
30
|
+
# Selenium::WebDriver.logger.output = 'selenium.log'
|
31
|
+
#
|
32
|
+
# @example Use logger manually
|
33
|
+
# Selenium::WebDriver.logger.info('This is info message')
|
34
|
+
# Selenium::WebDriver.logger.warn('This is warning message')
|
35
|
+
#
|
36
|
+
class Logger
|
37
|
+
extend Forwardable
|
38
|
+
|
39
|
+
def_delegators :@logger,
|
40
|
+
:close,
|
41
|
+
:debug, :debug?,
|
42
|
+
:info, :info?,
|
43
|
+
:warn, :warn?,
|
44
|
+
:error, :error?,
|
45
|
+
:fatal, :fatal?,
|
46
|
+
:level, :level=
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
@logger = create_logger($stdout)
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Changes logger output to a new IO.
|
54
|
+
#
|
55
|
+
# @param [String] io
|
56
|
+
#
|
57
|
+
def output=(io)
|
58
|
+
@logger.reopen(io)
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Returns IO object used by logger internally.
|
63
|
+
#
|
64
|
+
# Normally, we would have never needed it, but we want to
|
65
|
+
# use it as IO object for all child processes to ensure their
|
66
|
+
# output is redirected there.
|
67
|
+
#
|
68
|
+
# It is only used in debug level, in other cases output is suppressed.
|
69
|
+
#
|
70
|
+
# @api private
|
71
|
+
#
|
72
|
+
def io
|
73
|
+
@logger.instance_variable_get(:@logdev).dev
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Marks code as deprecated with/without replacement.
|
78
|
+
#
|
79
|
+
# @param [String] old
|
80
|
+
# @param [String, nil] new
|
81
|
+
#
|
82
|
+
def deprecate(old, new = nil)
|
83
|
+
message = +"[DEPRECATION] #{old} is deprecated"
|
84
|
+
message << if new
|
85
|
+
". Use #{new} instead."
|
86
|
+
else
|
87
|
+
' and will be removed in the next releases.'
|
88
|
+
end
|
89
|
+
|
90
|
+
warn message
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
def create_logger(output)
|
96
|
+
logger = ::Logger.new(output)
|
97
|
+
logger.progname = 'Selenium'
|
98
|
+
logger.level = default_level
|
99
|
+
logger.formatter = proc do |severity, time, progname, msg|
|
100
|
+
"#{time.strftime('%F %T')} #{severity} #{progname} #{msg}\n"
|
101
|
+
end
|
102
|
+
|
103
|
+
logger
|
104
|
+
end
|
105
|
+
|
106
|
+
def default_level
|
107
|
+
if $DEBUG || ENV.key?('DEBUG')
|
108
|
+
:debug
|
109
|
+
else
|
110
|
+
:warn
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end # Logger
|
114
|
+
end # WebDriver
|
115
|
+
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
|
@@ -20,7 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
class Logs
|
23
|
-
|
24
23
|
#
|
25
24
|
# @api private
|
26
25
|
#
|
@@ -30,13 +29,12 @@ module Selenium
|
|
30
29
|
end
|
31
30
|
|
32
31
|
def get(type)
|
33
|
-
@bridge.
|
32
|
+
@bridge.log type
|
34
33
|
end
|
35
34
|
|
36
35
|
def available_types
|
37
|
-
@bridge.
|
36
|
+
@bridge.available_log_types
|
38
37
|
end
|
39
|
-
|
40
38
|
end # Logs
|
41
39
|
end # WebDriver
|
42
40
|
end # Selenium
|
@@ -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,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,14 +19,12 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
|
23
22
|
#
|
24
23
|
# @api private
|
25
24
|
# @see ActionBuilder
|
26
25
|
#
|
27
26
|
|
28
27
|
class Mouse
|
29
|
-
|
30
28
|
def initialize(bridge)
|
31
29
|
@bridge = bridge
|
32
30
|
end
|
@@ -38,22 +36,22 @@ module Selenium
|
|
38
36
|
|
39
37
|
def double_click(element = nil)
|
40
38
|
move_if_needed element
|
41
|
-
@bridge.
|
39
|
+
@bridge.double_click
|
42
40
|
end
|
43
41
|
|
44
42
|
def context_click(element = nil)
|
45
43
|
move_if_needed element
|
46
|
-
@bridge.
|
44
|
+
@bridge.context_click
|
47
45
|
end
|
48
46
|
|
49
47
|
def down(element = nil)
|
50
48
|
move_if_needed element
|
51
|
-
@bridge.
|
49
|
+
@bridge.mouse_down
|
52
50
|
end
|
53
51
|
|
54
52
|
def up(element = nil)
|
55
53
|
move_if_needed element
|
56
|
-
@bridge.
|
54
|
+
@bridge.mouse_up
|
57
55
|
end
|
58
56
|
|
59
57
|
#
|
@@ -68,11 +66,11 @@ module Selenium
|
|
68
66
|
def move_to(element, right_by = nil, down_by = nil)
|
69
67
|
assert_element element
|
70
68
|
|
71
|
-
@bridge.
|
69
|
+
@bridge.mouse_move_to element.ref, right_by, down_by
|
72
70
|
end
|
73
71
|
|
74
72
|
def move_by(right_by, down_by)
|
75
|
-
@bridge.
|
73
|
+
@bridge.mouse_move_to nil, Integer(right_by), Integer(down_by)
|
76
74
|
end
|
77
75
|
|
78
76
|
private
|
@@ -82,10 +80,10 @@ module Selenium
|
|
82
80
|
end
|
83
81
|
|
84
82
|
def assert_element(element)
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
return if element.is_a? Element
|
84
|
+
|
85
|
+
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
|
88
86
|
end
|
89
87
|
end # Mouse
|
90
88
|
end # WebDriver
|
91
|
-
end
|
89
|
+
end # Selenium
|