selenium-webdriver 4.0.0.alpha1 → 4.0.0.alpha2
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 +8 -1
- data/lib/selenium/webdriver/version.rb +1 -1
- metadata +2 -26
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +0 -36
- data/lib/selenium/webdriver/common/keyboard.rb +0 -70
- data/lib/selenium/webdriver/common/mouse.rb +0 -89
- data/lib/selenium/webdriver/common/options.rb +0 -177
- data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
- data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
- data/lib/selenium/webdriver/common/w3c_manager.rb +0 -45
- data/lib/selenium/webdriver/common/w3c_options.rb +0 -45
- data/lib/selenium/webdriver/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
- data/lib/selenium/webdriver/firefox/marionette/bridge.rb +0 -49
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/util.rb +0 -46
- data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
- data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
- data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfdda64a93649dd407e9a99d0547280f33492826
|
4
|
+
data.tar.gz: 7c643c63e461f17cabb016812cffa21e3001f813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5b8faba158cabc734b9f0fa8e7fc00bdea0b127bafc2b6f363cefd3bc2aea78d176cc5d042eda9c2271d1dd52d951bd93c8449fdb381e7fa35ebafab3ffe88f
|
7
|
+
data.tar.gz: 113f4c13373c915447172e43cc5da4435bc785693c06e6a119f9ecdd5fcd3efc01a43b8d295f655be00e5176e3a901f721d6cfa053a606639e5c0b5d5092ecc5
|
data/CHANGES
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
4.0.0.
|
1
|
+
4.0.0.alpha2 (2019-05-02)
|
2
|
+
=========================
|
3
|
+
|
4
|
+
Ruby:
|
5
|
+
* Fixed an issue with previous alpha release which lead to removed files
|
6
|
+
being packaged inside the gem
|
7
|
+
|
8
|
+
4.0.0.alpha1 (2019-05-01)
|
2
9
|
=========================
|
3
10
|
|
4
11
|
Ruby:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium-webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-05-
|
13
|
+
date: 2019-05-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,7 +208,6 @@ files:
|
|
208
208
|
- lib/selenium/webdriver/common.rb
|
209
209
|
- lib/selenium/webdriver/common/action_builder.rb
|
210
210
|
- lib/selenium/webdriver/common/alert.rb
|
211
|
-
- lib/selenium/webdriver/common/bridge_helper.rb
|
212
211
|
- lib/selenium/webdriver/common/driver.rb
|
213
212
|
- lib/selenium/webdriver/common/driver_extensions/downloads_files.rb
|
214
213
|
- lib/selenium/webdriver/common/driver_extensions/has_addons.rb
|
@@ -219,7 +218,6 @@ files:
|
|
219
218
|
- lib/selenium/webdriver/common/driver_extensions/has_permissions.rb
|
220
219
|
- lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb
|
221
220
|
- lib/selenium/webdriver/common/driver_extensions/has_session_id.rb
|
222
|
-
- lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb
|
223
221
|
- lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb
|
224
222
|
- lib/selenium/webdriver/common/driver_extensions/rotatable.rb
|
225
223
|
- lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb
|
@@ -238,15 +236,12 @@ files:
|
|
238
236
|
- lib/selenium/webdriver/common/interactions/none_input.rb
|
239
237
|
- lib/selenium/webdriver/common/interactions/pointer_actions.rb
|
240
238
|
- lib/selenium/webdriver/common/interactions/pointer_input.rb
|
241
|
-
- lib/selenium/webdriver/common/keyboard.rb
|
242
239
|
- lib/selenium/webdriver/common/keys.rb
|
243
240
|
- lib/selenium/webdriver/common/log_entry.rb
|
244
241
|
- lib/selenium/webdriver/common/logger.rb
|
245
242
|
- lib/selenium/webdriver/common/logs.rb
|
246
243
|
- lib/selenium/webdriver/common/manager.rb
|
247
|
-
- lib/selenium/webdriver/common/mouse.rb
|
248
244
|
- lib/selenium/webdriver/common/navigation.rb
|
249
|
-
- lib/selenium/webdriver/common/options.rb
|
250
245
|
- lib/selenium/webdriver/common/platform.rb
|
251
246
|
- lib/selenium/webdriver/common/port_prober.rb
|
252
247
|
- lib/selenium/webdriver/common/profile_helper.rb
|
@@ -257,16 +252,10 @@ files:
|
|
257
252
|
- lib/selenium/webdriver/common/socket_poller.rb
|
258
253
|
- lib/selenium/webdriver/common/target_locator.rb
|
259
254
|
- lib/selenium/webdriver/common/timeouts.rb
|
260
|
-
- lib/selenium/webdriver/common/touch_action_builder.rb
|
261
|
-
- lib/selenium/webdriver/common/touch_screen.rb
|
262
|
-
- lib/selenium/webdriver/common/w3c_action_builder.rb
|
263
|
-
- lib/selenium/webdriver/common/w3c_manager.rb
|
264
|
-
- lib/selenium/webdriver/common/w3c_options.rb
|
265
255
|
- lib/selenium/webdriver/common/wait.rb
|
266
256
|
- lib/selenium/webdriver/common/window.rb
|
267
257
|
- lib/selenium/webdriver/common/zipper.rb
|
268
258
|
- lib/selenium/webdriver/edge.rb
|
269
|
-
- lib/selenium/webdriver/edge/bridge.rb
|
270
259
|
- lib/selenium/webdriver/edge/driver.rb
|
271
260
|
- lib/selenium/webdriver/edge/options.rb
|
272
261
|
- lib/selenium/webdriver/edge/service.rb
|
@@ -276,18 +265,10 @@ files:
|
|
276
265
|
- lib/selenium/webdriver/firefox/driver.rb
|
277
266
|
- lib/selenium/webdriver/firefox/extension.rb
|
278
267
|
- lib/selenium/webdriver/firefox/extension/prefs.json
|
279
|
-
- lib/selenium/webdriver/firefox/extension/webdriver.xpi
|
280
|
-
- lib/selenium/webdriver/firefox/launcher.rb
|
281
|
-
- lib/selenium/webdriver/firefox/legacy/driver.rb
|
282
|
-
- lib/selenium/webdriver/firefox/marionette/bridge.rb
|
283
|
-
- lib/selenium/webdriver/firefox/marionette/driver.rb
|
284
|
-
- lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so
|
285
|
-
- lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so
|
286
268
|
- lib/selenium/webdriver/firefox/options.rb
|
287
269
|
- lib/selenium/webdriver/firefox/profile.rb
|
288
270
|
- lib/selenium/webdriver/firefox/profiles_ini.rb
|
289
271
|
- lib/selenium/webdriver/firefox/service.rb
|
290
|
-
- lib/selenium/webdriver/firefox/util.rb
|
291
272
|
- lib/selenium/webdriver/ie.rb
|
292
273
|
- lib/selenium/webdriver/ie/driver.rb
|
293
274
|
- lib/selenium/webdriver/ie/options.rb
|
@@ -301,13 +282,8 @@ files:
|
|
301
282
|
- lib/selenium/webdriver/remote/http/curb.rb
|
302
283
|
- lib/selenium/webdriver/remote/http/default.rb
|
303
284
|
- lib/selenium/webdriver/remote/http/persistent.rb
|
304
|
-
- lib/selenium/webdriver/remote/oss/bridge.rb
|
305
|
-
- lib/selenium/webdriver/remote/oss/commands.rb
|
306
285
|
- lib/selenium/webdriver/remote/response.rb
|
307
286
|
- lib/selenium/webdriver/remote/server_error.rb
|
308
|
-
- lib/selenium/webdriver/remote/w3c/bridge.rb
|
309
|
-
- lib/selenium/webdriver/remote/w3c/capabilities.rb
|
310
|
-
- lib/selenium/webdriver/remote/w3c/commands.rb
|
311
287
|
- lib/selenium/webdriver/safari.rb
|
312
288
|
- lib/selenium/webdriver/safari/bridge.rb
|
313
289
|
- lib/selenium/webdriver/safari/driver.rb
|
@@ -1,82 +0,0 @@
|
|
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
|
-
#
|
23
|
-
# Shared across bridges
|
24
|
-
#
|
25
|
-
# @api private
|
26
|
-
#
|
27
|
-
|
28
|
-
module BridgeHelper
|
29
|
-
def unwrap_script_result(arg)
|
30
|
-
case arg
|
31
|
-
when Array
|
32
|
-
arg.map { |e| unwrap_script_result(e) }
|
33
|
-
when Hash
|
34
|
-
element_id = element_id_from(arg)
|
35
|
-
return Element.new(self, element_id) if element_id
|
36
|
-
|
37
|
-
arg.each { |k, v| arg[k] = unwrap_script_result(v) }
|
38
|
-
else
|
39
|
-
arg
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def element_id_from(id)
|
44
|
-
id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
|
45
|
-
end
|
46
|
-
|
47
|
-
def parse_cookie_string(str)
|
48
|
-
result = {
|
49
|
-
'name' => '',
|
50
|
-
'value' => '',
|
51
|
-
'domain' => '',
|
52
|
-
'path' => '',
|
53
|
-
'expires' => '',
|
54
|
-
'secure' => false
|
55
|
-
}
|
56
|
-
|
57
|
-
str.split(';').each do |attribute|
|
58
|
-
if attribute.include? '='
|
59
|
-
key, value = attribute.strip.split('=', 2)
|
60
|
-
if result['name'].empty?
|
61
|
-
result['name'] = key
|
62
|
-
result['value'] = value
|
63
|
-
elsif key == 'domain' && value.strip =~ /^\.(.+)/
|
64
|
-
result['domain'] = Regexp.last_match(1)
|
65
|
-
elsif key && value
|
66
|
-
result[key] = value
|
67
|
-
end
|
68
|
-
elsif attribute == 'secure'
|
69
|
-
result['secure'] = true
|
70
|
-
end
|
71
|
-
|
72
|
-
unless [nil, '', '0'].include?(result['expires'])
|
73
|
-
# firefox stores expiry as number of seconds
|
74
|
-
result['expires'] = Time.at(result['expires'].to_i)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
result
|
79
|
-
end
|
80
|
-
end # BridgeHelper
|
81
|
-
end # WebDriver
|
82
|
-
end # Selenium
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
-
# or more contributor license agreements. See the NOTICE file
|
5
|
-
# distributed with this work for additional information
|
6
|
-
# regarding copyright ownership. The SFC licenses this file
|
7
|
-
# to you under the Apache License, Version 2.0 (the
|
8
|
-
# "License"); you may not use this file except in compliance
|
9
|
-
# with the License. You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing,
|
14
|
-
# software distributed under the License is distributed on an
|
15
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
-
# KIND, either express or implied. See the License for the
|
17
|
-
# specific language governing permissions and limitations
|
18
|
-
# under the License.
|
19
|
-
|
20
|
-
module Selenium
|
21
|
-
module WebDriver
|
22
|
-
module DriverExtensions
|
23
|
-
module HasTouchScreen
|
24
|
-
def touch
|
25
|
-
TouchActionBuilder.new Mouse.new(@bridge), Keyboard.new(@bridge), touch_screen
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def touch_screen
|
31
|
-
TouchScreen.new @bridge
|
32
|
-
end
|
33
|
-
end # HasTouchScreen
|
34
|
-
end # DriverExtensions
|
35
|
-
end # WebDriver
|
36
|
-
end # Selenium
|
@@ -1,70 +0,0 @@
|
|
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
|
-
#
|
23
|
-
# @api private
|
24
|
-
# @see ActionBuilder
|
25
|
-
|
26
|
-
class Keyboard
|
27
|
-
def initialize(bridge)
|
28
|
-
@bridge = bridge
|
29
|
-
end
|
30
|
-
|
31
|
-
def send_keys(*keys)
|
32
|
-
@bridge.send_keys_to_active_element Keys.encode(keys)
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# Press a modifier key
|
37
|
-
#
|
38
|
-
# @see Selenium::WebDriver::Keys
|
39
|
-
#
|
40
|
-
|
41
|
-
def press(key)
|
42
|
-
assert_modifier key
|
43
|
-
|
44
|
-
@bridge.send_keys_to_active_element Keys.encode([key])
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# Release a modifier key
|
49
|
-
#
|
50
|
-
# @see Selenium::WebDriver::Keys
|
51
|
-
#
|
52
|
-
|
53
|
-
def release(key)
|
54
|
-
assert_modifier key
|
55
|
-
|
56
|
-
@bridge.send_keys_to_active_element Keys.encode([key])
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
MODIFIERS = %i[control shift alt command meta].freeze
|
62
|
-
|
63
|
-
def assert_modifier(key)
|
64
|
-
return if MODIFIERS.include? key
|
65
|
-
|
66
|
-
raise ArgumentError, "#{key.inspect} is not a modifier key, expected one of #{MODIFIERS.inspect}"
|
67
|
-
end
|
68
|
-
end # Keyboard
|
69
|
-
end # WebDriver
|
70
|
-
end # Selenium
|
@@ -1,89 +0,0 @@
|
|
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
|
-
#
|
23
|
-
# @api private
|
24
|
-
# @see ActionBuilder
|
25
|
-
#
|
26
|
-
|
27
|
-
class Mouse
|
28
|
-
def initialize(bridge)
|
29
|
-
@bridge = bridge
|
30
|
-
end
|
31
|
-
|
32
|
-
def click(element = nil)
|
33
|
-
move_if_needed element
|
34
|
-
@bridge.click
|
35
|
-
end
|
36
|
-
|
37
|
-
def double_click(element = nil)
|
38
|
-
move_if_needed element
|
39
|
-
@bridge.double_click
|
40
|
-
end
|
41
|
-
|
42
|
-
def context_click(element = nil)
|
43
|
-
move_if_needed element
|
44
|
-
@bridge.context_click
|
45
|
-
end
|
46
|
-
|
47
|
-
def down(element = nil)
|
48
|
-
move_if_needed element
|
49
|
-
@bridge.mouse_down
|
50
|
-
end
|
51
|
-
|
52
|
-
def up(element = nil)
|
53
|
-
move_if_needed element
|
54
|
-
@bridge.mouse_up
|
55
|
-
end
|
56
|
-
|
57
|
-
#
|
58
|
-
# Move the mouse.
|
59
|
-
#
|
60
|
-
# Examples:
|
61
|
-
#
|
62
|
-
# driver.mouse.move_to(element)
|
63
|
-
# driver.mouse.move_to(element, 5, 5)
|
64
|
-
#
|
65
|
-
|
66
|
-
def move_to(element, right_by = nil, down_by = nil)
|
67
|
-
assert_element element
|
68
|
-
|
69
|
-
@bridge.mouse_move_to element.ref, right_by, down_by
|
70
|
-
end
|
71
|
-
|
72
|
-
def move_by(right_by, down_by)
|
73
|
-
@bridge.mouse_move_to nil, Integer(right_by), Integer(down_by)
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def move_if_needed(element)
|
79
|
-
move_to element if element
|
80
|
-
end
|
81
|
-
|
82
|
-
def assert_element(element)
|
83
|
-
return if element.is_a? Element
|
84
|
-
|
85
|
-
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
|
86
|
-
end
|
87
|
-
end # Mouse
|
88
|
-
end # WebDriver
|
89
|
-
end # Selenium
|
@@ -1,177 +0,0 @@
|
|
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 Options
|
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
|