selenium-webdriver 4.0.0.alpha1 → 4.0.0.alpha6
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 +5 -5
- data/CHANGES +139 -1
- data/LICENSE +1 -1
- data/lib/selenium/server.rb +3 -3
- data/lib/selenium/webdriver.rb +11 -7
- data/lib/selenium/webdriver/atoms/findElements.js +122 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +84 -7
- data/lib/selenium/webdriver/atoms/isDisplayed.js +75 -77
- data/lib/selenium/webdriver/chrome.rb +10 -9
- data/lib/selenium/webdriver/chrome/bridge.rb +20 -4
- data/lib/selenium/webdriver/chrome/driver.rb +3 -52
- data/lib/selenium/webdriver/chrome/options.rb +97 -57
- data/lib/selenium/webdriver/chrome/profile.rb +2 -2
- data/lib/selenium/webdriver/chrome/service.rb +0 -4
- data/lib/selenium/webdriver/common.rb +3 -0
- data/lib/selenium/webdriver/common/driver.rb +76 -17
- data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_devtools.rb} +10 -8
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -1
- data/lib/selenium/webdriver/common/logger.rb +48 -16
- data/lib/selenium/webdriver/common/manager.rb +5 -0
- data/lib/selenium/webdriver/common/options.rb +60 -121
- data/lib/selenium/webdriver/common/platform.rb +3 -0
- data/lib/selenium/webdriver/common/port_prober.rb +4 -6
- data/lib/selenium/webdriver/common/profile_helper.rb +10 -2
- data/lib/selenium/webdriver/common/proxy.rb +0 -0
- data/lib/selenium/webdriver/common/search_context.rb +3 -2
- data/lib/selenium/webdriver/common/service.rb +30 -113
- data/lib/selenium/webdriver/common/service_manager.rb +151 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
- data/lib/selenium/webdriver/common/wait.rb +1 -1
- data/lib/selenium/webdriver/devtools.rb +118 -0
- data/lib/selenium/webdriver/devtools/accessibility.rb +62 -0
- data/lib/selenium/webdriver/devtools/animation.rb +98 -0
- data/lib/selenium/webdriver/devtools/application_cache.rb +64 -0
- data/lib/selenium/webdriver/devtools/audits.rb +61 -0
- data/lib/selenium/webdriver/devtools/background_service.rb +67 -0
- data/lib/selenium/webdriver/devtools/browser.rb +123 -0
- data/lib/selenium/webdriver/devtools/cache_storage.rb +73 -0
- data/lib/selenium/webdriver/devtools/cast.rb +70 -0
- data/lib/selenium/webdriver/devtools/console.rb +57 -0
- data/lib/selenium/webdriver/devtools/css.rb +165 -0
- data/lib/selenium/webdriver/devtools/database.rb +64 -0
- data/lib/selenium/webdriver/devtools/debugger.rb +229 -0
- data/lib/selenium/webdriver/devtools/device_orientation.rb +53 -0
- data/lib/selenium/webdriver/devtools/dom.rb +320 -0
- data/lib/selenium/webdriver/devtools/domdebugger.rb +93 -0
- data/lib/selenium/webdriver/devtools/domsnapshot.rb +65 -0
- data/lib/selenium/webdriver/devtools/domstorage.rb +79 -0
- data/lib/selenium/webdriver/devtools/emulation.rb +180 -0
- data/lib/selenium/webdriver/devtools/fetch.rb +97 -0
- data/lib/selenium/webdriver/devtools/headless_experimental.rb +61 -0
- data/lib/selenium/webdriver/devtools/heap_profiler.rb +107 -0
- data/lib/selenium/webdriver/devtools/indexed_db.rb +100 -0
- data/lib/selenium/webdriver/devtools/input.rb +140 -0
- data/lib/selenium/webdriver/devtools/inspector.rb +55 -0
- data/lib/selenium/webdriver/devtools/io.rb +59 -0
- data/lib/selenium/webdriver/devtools/layer_tree.rb +95 -0
- data/lib/selenium/webdriver/devtools/log.rb +66 -0
- data/lib/selenium/webdriver/devtools/media.rb +57 -0
- data/lib/selenium/webdriver/devtools/memory.rb +86 -0
- data/lib/selenium/webdriver/devtools/network.rb +228 -0
- data/lib/selenium/webdriver/devtools/overlay.rb +157 -0
- data/lib/selenium/webdriver/devtools/page.rb +374 -0
- data/lib/selenium/webdriver/devtools/performance.rb +63 -0
- data/lib/selenium/webdriver/devtools/profiler.rb +111 -0
- data/lib/selenium/webdriver/devtools/runtime.rb +193 -0
- data/lib/selenium/webdriver/devtools/schema.rb +46 -0
- data/lib/selenium/webdriver/devtools/security.rb +71 -0
- data/lib/selenium/webdriver/devtools/service_worker.rb +116 -0
- data/lib/selenium/webdriver/devtools/storage.rb +95 -0
- data/lib/selenium/webdriver/devtools/system_info.rb +50 -0
- data/lib/selenium/webdriver/devtools/target.rb +141 -0
- data/lib/selenium/webdriver/devtools/tethering.rb +55 -0
- data/lib/selenium/webdriver/devtools/tracing.rb +76 -0
- data/lib/selenium/webdriver/devtools/web_audio.rb +70 -0
- data/lib/selenium/webdriver/devtools/web_authn.rb +94 -0
- data/lib/selenium/webdriver/edge.rb +29 -9
- data/lib/selenium/webdriver/{firefox/util.rb → edge_chrome/bridge.rb} +11 -20
- data/lib/selenium/webdriver/{common/w3c_options.rb → edge_chrome/driver.rb} +14 -17
- data/lib/selenium/webdriver/edge_chrome/options.rb +36 -0
- data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
- data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
- data/lib/selenium/webdriver/{common/w3c_manager.rb → edge_html/driver.rb} +11 -17
- data/lib/selenium/webdriver/{edge → edge_html}/options.rb +26 -22
- data/lib/selenium/webdriver/{edge → edge_html}/service.rb +2 -6
- data/lib/selenium/webdriver/firefox.rb +18 -15
- data/lib/selenium/webdriver/firefox/bridge.rb +1 -1
- data/lib/selenium/webdriver/firefox/driver.rb +2 -30
- data/lib/selenium/webdriver/firefox/extension.rb +8 -0
- data/lib/selenium/webdriver/firefox/options.rb +47 -52
- data/lib/selenium/webdriver/firefox/profile.rb +7 -78
- data/lib/selenium/webdriver/firefox/service.rb +0 -4
- data/lib/selenium/webdriver/ie.rb +8 -7
- data/lib/selenium/webdriver/ie/driver.rb +0 -32
- data/lib/selenium/webdriver/ie/options.rb +10 -33
- data/lib/selenium/webdriver/ie/service.rb +5 -9
- data/lib/selenium/webdriver/remote.rb +16 -10
- data/lib/selenium/webdriver/remote/bridge.rb +34 -42
- data/lib/selenium/webdriver/remote/capabilities.rb +22 -6
- data/lib/selenium/webdriver/remote/driver.rb +6 -12
- data/lib/selenium/webdriver/remote/http/default.rb +9 -4
- data/lib/selenium/webdriver/remote/http/persistent.rb +5 -6
- data/lib/selenium/webdriver/safari.rb +9 -8
- data/lib/selenium/webdriver/safari/bridge.rb +4 -4
- data/lib/selenium/webdriver/safari/driver.rb +3 -29
- data/lib/selenium/webdriver/safari/options.rb +18 -19
- data/lib/selenium/webdriver/safari/service.rb +0 -4
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +77 -0
- data/lib/selenium/webdriver/support/color.rb +2 -2
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +1 -1
- data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
- data/lib/selenium/webdriver/version.rb +1 -1
- data/selenium-webdriver.gemspec +5 -4
- metadata +81 -42
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/keyboard.rb +0 -70
- data/lib/selenium/webdriver/common/mouse.rb +0 -89
- 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/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/edge/driver.rb +0 -70
- data/lib/selenium/webdriver/firefox/binary.rb +0 -110
- data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
- 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/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
|
@@ -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,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,78 +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 TouchActionBuilder < ActionBuilder
|
|
23
|
-
#
|
|
24
|
-
# @api private
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
def initialize(mouse, keyboard, touch_screen)
|
|
28
|
-
WebDriver.logger.deprecate(self.class.name)
|
|
29
|
-
super(mouse, keyboard)
|
|
30
|
-
@devices[:touch_screen] = touch_screen
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def scroll(*args)
|
|
34
|
-
raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}" unless [2, 3].include? args.size
|
|
35
|
-
|
|
36
|
-
@actions << [:touch_screen, :scroll, args]
|
|
37
|
-
self
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def flick(*args)
|
|
41
|
-
raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}" unless [2, 4].include? args.size
|
|
42
|
-
|
|
43
|
-
@actions << [:touch_screen, :flick, args]
|
|
44
|
-
self
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def single_tap(element)
|
|
48
|
-
@actions << [:touch_screen, :single_tap, [element]]
|
|
49
|
-
self
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def double_tap(element)
|
|
53
|
-
@actions << [:touch_screen, :double_tap, [element]]
|
|
54
|
-
self
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def long_press(element)
|
|
58
|
-
@actions << [:touch_screen, :long_press, [element]]
|
|
59
|
-
self
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def down(x, y = nil)
|
|
63
|
-
@actions << [:touch_screen, :down, [x, y]]
|
|
64
|
-
self
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def up(x, y = nil)
|
|
68
|
-
@actions << [:touch_screen, :up, [x, y]]
|
|
69
|
-
self
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def move(x, y = nil)
|
|
73
|
-
@actions << [:touch_screen, :move, [x, y]]
|
|
74
|
-
self
|
|
75
|
-
end
|
|
76
|
-
end # TouchActionBuilder
|
|
77
|
-
end # WebDriver
|
|
78
|
-
end # Selenium
|
|
@@ -1,123 +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 TouchScreen
|
|
23
|
-
FLICK_SPEED = {normal: 0, fast: 1}.freeze
|
|
24
|
-
|
|
25
|
-
#
|
|
26
|
-
# @api private
|
|
27
|
-
#
|
|
28
|
-
|
|
29
|
-
def initialize(bridge)
|
|
30
|
-
@bridge = bridge
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def single_tap(element)
|
|
34
|
-
assert_element element
|
|
35
|
-
@bridge.touch_single_tap element.ref
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def double_tap(element)
|
|
39
|
-
assert_element element
|
|
40
|
-
@bridge.touch_double_tap element.ref
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def long_press(element)
|
|
44
|
-
assert_element element
|
|
45
|
-
@bridge.touch_long_press element.ref
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def down(x, y = nil)
|
|
49
|
-
x, y = coords_from x, y
|
|
50
|
-
@bridge.touch_down x, y
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def up(x, y = nil)
|
|
54
|
-
x, y = coords_from x, y
|
|
55
|
-
@bridge.touch_up x, y
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def move(x, y = nil)
|
|
59
|
-
x, y = coords_from x, y
|
|
60
|
-
@bridge.touch_move x, y
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def scroll(*args)
|
|
64
|
-
case args.size
|
|
65
|
-
when 2
|
|
66
|
-
x_offset, y_offset = args
|
|
67
|
-
@bridge.touch_scroll nil, Integer(x_offset), Integer(y_offset)
|
|
68
|
-
when 3
|
|
69
|
-
element, x_offset, y_offset = args
|
|
70
|
-
assert_element element
|
|
71
|
-
@bridge.touch_scroll element.ref, Integer(x_offset), Integer(y_offset)
|
|
72
|
-
else
|
|
73
|
-
raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}"
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def flick(*args)
|
|
78
|
-
case args.size
|
|
79
|
-
when 2
|
|
80
|
-
x_speed, y_speed = args
|
|
81
|
-
@bridge.touch_flick Integer(x_speed), Integer(y_speed)
|
|
82
|
-
when 4
|
|
83
|
-
element, xoffset, yoffset, speed = args
|
|
84
|
-
|
|
85
|
-
assert_element element
|
|
86
|
-
|
|
87
|
-
if (speed.is_a?(String) || speed.is_a?(Symbol)) && FLICK_SPEED.key?(speed.to_sym)
|
|
88
|
-
WebDriver.logger.deprecate "Passing #{speed.inspect} speed",
|
|
89
|
-
"Integer or Selenium::WebDriver::TouchScreen::FLICK_SPEED[:#{speed}]"
|
|
90
|
-
speed = FLICK_SPEED[speed.to_sym]
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
@bridge.touch_element_flick element.ref, Integer(xoffset), Integer(yoffset), Integer(speed)
|
|
94
|
-
else
|
|
95
|
-
raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}"
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
private
|
|
100
|
-
|
|
101
|
-
def coords_from(x, y)
|
|
102
|
-
if y.nil?
|
|
103
|
-
point = x
|
|
104
|
-
|
|
105
|
-
unless point.respond_to?(:x) && point.respond_to?(:y)
|
|
106
|
-
raise ArgumentError, "expected #{point.inspect} to respond to :x and :y"
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
x = point.x
|
|
110
|
-
y = point.y
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
[Integer(x), Integer(y)]
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def assert_element(element)
|
|
117
|
-
return if element.is_a? Element
|
|
118
|
-
|
|
119
|
-
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
|
|
120
|
-
end
|
|
121
|
-
end # TouchScreen
|
|
122
|
-
end # WebDriver
|
|
123
|
-
end # Selenium
|
|
@@ -1,212 +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 W3CActionBuilder
|
|
23
|
-
include KeyActions # Actions specific to key inputs
|
|
24
|
-
include PointerActions # Actions specific to pointer inputs
|
|
25
|
-
attr_reader :devices
|
|
26
|
-
|
|
27
|
-
#
|
|
28
|
-
# Initialize a W3C Action Builder. Differs from previous by requiring a bridge and allowing asynchronous actions.
|
|
29
|
-
# The W3C implementation allows asynchronous actions per device. e.g. A key can be pressed at the same time that
|
|
30
|
-
# the mouse is moving. Keep in mind that pauses must be added for other devices in order to line up the actions
|
|
31
|
-
# correctly when using asynchronous.
|
|
32
|
-
#
|
|
33
|
-
# @param [Selenium::WebDriver::Remote::W3CBridge] bridge the bridge for the current driver instance
|
|
34
|
-
# @param [Selenium::WebDriver::Interactions::PointerInput] mouse PointerInput for the mouse.
|
|
35
|
-
# @param [Selenium::WebDriver::Interactions::KeyInput] keyboard KeyInput for the keyboard.
|
|
36
|
-
# @param [Boolean] async Whether to perform the actions asynchronously per device. Defaults to false for
|
|
37
|
-
# backwards compatibility.
|
|
38
|
-
# @return [W3CActionBuilder] A self reference.
|
|
39
|
-
#
|
|
40
|
-
|
|
41
|
-
def initialize(bridge, mouse, keyboard, async = false)
|
|
42
|
-
# For backwards compatibility, automatically include mouse & keyboard
|
|
43
|
-
@bridge = bridge
|
|
44
|
-
@devices = [mouse, keyboard]
|
|
45
|
-
@async = async
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
#
|
|
49
|
-
# Adds a PointerInput device of the given kind
|
|
50
|
-
#
|
|
51
|
-
# @example Add a touch pointer input device
|
|
52
|
-
#
|
|
53
|
-
# builder = device.action
|
|
54
|
-
# builder.add_pointer_input('touch', :touch)
|
|
55
|
-
#
|
|
56
|
-
# @param [String] name name for the device
|
|
57
|
-
# @param [Symbol] kind kind of pointer device to create
|
|
58
|
-
# @return [Interactions::PointerInput] The pointer input added
|
|
59
|
-
#
|
|
60
|
-
#
|
|
61
|
-
|
|
62
|
-
def add_pointer_input(kind, name)
|
|
63
|
-
new_input = Interactions.pointer(kind, name: name)
|
|
64
|
-
add_input(new_input)
|
|
65
|
-
new_input
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
#
|
|
69
|
-
# Adds a KeyInput device
|
|
70
|
-
#
|
|
71
|
-
# @example Add a key input device
|
|
72
|
-
#
|
|
73
|
-
# builder = device.action
|
|
74
|
-
# builder.add_key_input('keyboard2')
|
|
75
|
-
#
|
|
76
|
-
# @param [String] name name for the device
|
|
77
|
-
# @return [Interactions::KeyInput] The key input added
|
|
78
|
-
#
|
|
79
|
-
|
|
80
|
-
def add_key_input(name)
|
|
81
|
-
new_input = Interactions.key(name)
|
|
82
|
-
add_input(new_input)
|
|
83
|
-
new_input
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
#
|
|
87
|
-
# Retrieves the input device for the given name
|
|
88
|
-
#
|
|
89
|
-
# @param [String] name name of the input device
|
|
90
|
-
# @return [Selenium::WebDriver::Interactions::InputDevice] input device with given name
|
|
91
|
-
#
|
|
92
|
-
|
|
93
|
-
def get_device(name)
|
|
94
|
-
@devices.find { |device| device.name == name.to_s }
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
#
|
|
98
|
-
# Retrieves the current PointerInput devices
|
|
99
|
-
#
|
|
100
|
-
# @return [Array] array of current PointerInput devices
|
|
101
|
-
#
|
|
102
|
-
|
|
103
|
-
def pointer_inputs
|
|
104
|
-
@devices.select { |device| device.type == Interactions::POINTER }
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
#
|
|
108
|
-
# Retrieves the current KeyInput device
|
|
109
|
-
#
|
|
110
|
-
# @return [Selenium::WebDriver::Interactions::InputDevice] current KeyInput device
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
def key_inputs
|
|
114
|
-
@devices.select { |device| device.type == Interactions::KEY }
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
#
|
|
118
|
-
# Creates a pause for the given device of the given duration. If no duration is given, the pause will only wait
|
|
119
|
-
# for all actions to complete in that tick.
|
|
120
|
-
#
|
|
121
|
-
# @example Send keys to an element
|
|
122
|
-
#
|
|
123
|
-
# action_builder = driver.action
|
|
124
|
-
# keyboard = action_builder.key_input
|
|
125
|
-
# el = driver.find_element(id: "some_id")
|
|
126
|
-
# driver.action.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys('keys').perform
|
|
127
|
-
#
|
|
128
|
-
# @param [InputDevice] device Input device to pause
|
|
129
|
-
# @param [Float] duration Duration to pause
|
|
130
|
-
# @return [W3CActionBuilder] A self reference.
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
def pause(device, duration = nil)
|
|
134
|
-
device.create_pause(duration)
|
|
135
|
-
self
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
#
|
|
139
|
-
# Creates multiple pauses for the given device of the given duration.
|
|
140
|
-
#
|
|
141
|
-
# @example Send keys to an element
|
|
142
|
-
#
|
|
143
|
-
# action_builder = driver.action
|
|
144
|
-
# keyboard = action_builder.key_input
|
|
145
|
-
# el = driver.find_element(id: "some_id")
|
|
146
|
-
# driver.action.click(el).pauses(keyboard, 3).send_keys('keys').perform
|
|
147
|
-
#
|
|
148
|
-
# @param [InputDevice] device Input device to pause
|
|
149
|
-
# @param [Integer] number of pauses to add for the device
|
|
150
|
-
# @param [Float] duration Duration to pause
|
|
151
|
-
# @return [W3CActionBuilder] A self reference.
|
|
152
|
-
#
|
|
153
|
-
|
|
154
|
-
def pauses(device, number, duration = nil)
|
|
155
|
-
number.times { device.create_pause(duration) }
|
|
156
|
-
self
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
#
|
|
160
|
-
# Executes the actions added to the builder.
|
|
161
|
-
#
|
|
162
|
-
|
|
163
|
-
def perform
|
|
164
|
-
@bridge.send_actions @devices.map(&:encode).compact
|
|
165
|
-
clear_all_actions
|
|
166
|
-
nil
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
#
|
|
170
|
-
# Clears all actions from the builder.
|
|
171
|
-
#
|
|
172
|
-
|
|
173
|
-
def clear_all_actions
|
|
174
|
-
@devices.each(&:clear_actions)
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
#
|
|
178
|
-
# Releases all action states from the browser.
|
|
179
|
-
#
|
|
180
|
-
|
|
181
|
-
def release_actions
|
|
182
|
-
@bridge.release_actions
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
private
|
|
186
|
-
|
|
187
|
-
#
|
|
188
|
-
# Adds pauses for all devices but the given devices
|
|
189
|
-
#
|
|
190
|
-
# @param [Array[InputDevice]] action_devices Array of Input Devices performing an action in this tick.
|
|
191
|
-
#
|
|
192
|
-
|
|
193
|
-
def tick(*action_devices)
|
|
194
|
-
return if @async
|
|
195
|
-
|
|
196
|
-
@devices.each { |device| device.create_pause unless action_devices.include? device }
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
#
|
|
200
|
-
# Adds an InputDevice
|
|
201
|
-
#
|
|
202
|
-
|
|
203
|
-
def add_input(device)
|
|
204
|
-
unless @async
|
|
205
|
-
max_device = @devices.max { |a, b| a.actions.length <=> b.actions.length }
|
|
206
|
-
pauses(device, max_device.actions.length)
|
|
207
|
-
end
|
|
208
|
-
@devices << device
|
|
209
|
-
end
|
|
210
|
-
end # W3CActionBuilder
|
|
211
|
-
end # WebDriver
|
|
212
|
-
end # Selenium
|