appium_lib_core 4.5.0 → 5.0.0.beta1
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/.github/workflows/unittest.yml +2 -2
- data/CHANGELOG.md +6 -0
- data/appium_lib_core.gemspec +4 -4
- data/lib/appium_lib_core/common/base.rb +0 -1
- data/lib/appium_lib_core/common/base/bridge.rb +17 -102
- data/lib/appium_lib_core/common/base/bridge/w3c.rb +102 -2
- data/lib/appium_lib_core/common/base/capabilities.rb +3 -3
- data/lib/appium_lib_core/common/base/command.rb +123 -2
- data/lib/appium_lib_core/common/base/driver.rb +58 -11
- data/lib/appium_lib_core/common/base/has_network_connection.rb +56 -0
- data/lib/appium_lib_core/common/command.rb +0 -1
- data/lib/appium_lib_core/device.rb +0 -4
- data/lib/appium_lib_core/driver.rb +4 -4
- data/lib/appium_lib_core/version.rb +2 -2
- data/script/commands.rb +2 -25
- metadata +14 -21
- data/lib/appium_lib_core/common/base/bridge/mjsonwp.rb +0 -91
- data/lib/appium_lib_core/common/command/mjsonwp.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd462f64262abe99f03dd5a421f2a2dd9c8064f1d44eff47bc1872a834793d27
|
4
|
+
data.tar.gz: 1a1ca492c3551d8c992e9f2b740460e67239887400602351423062e49912b73f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9e4977dfb93ce734c59af5053a6331bfc2038bd3a03757a31fd7e48c3cdcc810204fb6f3027a1120afe91eda31ad61aa504fa25fdf2a2a21d36638c27982f8e
|
7
|
+
data.tar.gz: 3e23c561984a3ad4bf4214aad79fc730f8673d0bc29c81d26ff5143c0dbeb38d6eacc9278ba0caa11e4dfc51f82267f79b97efe6937ad8315c837e64876df162
|
@@ -11,7 +11,7 @@ jobs:
|
|
11
11
|
strategy:
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
|
-
ruby: [2.
|
14
|
+
ruby: [2.5, 2.6, 2.7, 3.0]
|
15
15
|
|
16
16
|
runs-on: ubuntu-latest
|
17
17
|
|
@@ -38,7 +38,7 @@ jobs:
|
|
38
38
|
fail-fast: false
|
39
39
|
matrix:
|
40
40
|
# Does not add 2.7 on Windows so far since a command fails only on Windows
|
41
|
-
ruby: [2.
|
41
|
+
ruby: [2.5, 2.6]
|
42
42
|
|
43
43
|
runs-on: windows-latest
|
44
44
|
|
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,12 @@ Read `release_notes.md` for commit level details.
|
|
10
10
|
|
11
11
|
### Deprecations
|
12
12
|
|
13
|
+
## [5.0.0.beta1]
|
14
|
+
|
15
|
+
- Update base selenium webdriver version to `4.0.0.beta2`
|
16
|
+
- Support only W3C spec
|
17
|
+
- Support Ruby 2.5+
|
18
|
+
|
13
19
|
## [4.5.0] - 2021-03-14
|
14
20
|
|
15
21
|
### Enhancements
|
data/appium_lib_core.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'appium_lib_core/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.required_ruby_version = '>= 2.
|
7
|
+
spec.required_ruby_version = '>= 2.5'
|
8
8
|
|
9
9
|
spec.name = 'appium_lib_core'
|
10
10
|
spec.version = Appium::Core::VERSION
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_runtime_dependency 'selenium-webdriver', '
|
25
|
+
spec.add_runtime_dependency 'selenium-webdriver', '4.0.0.beta2'
|
26
26
|
spec.add_runtime_dependency 'faye-websocket', '~> 0.11.0'
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler', '>= 1.14'
|
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency 'yard', '~> 0.9.11'
|
31
31
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
32
32
|
spec.add_development_dependency 'minitest-reporters', '~> 1.1'
|
33
|
-
spec.add_development_dependency 'webmock', '~> 3.
|
34
|
-
spec.add_development_dependency 'rubocop', '1.
|
33
|
+
spec.add_development_dependency 'webmock', '~> 3.12.1'
|
34
|
+
spec.add_development_dependency 'rubocop', '1.11.0'
|
35
35
|
spec.add_development_dependency 'appium_thor', '~> 1.0'
|
36
36
|
spec.add_development_dependency 'pry'
|
37
37
|
spec.add_development_dependency 'pry-byebug'
|
@@ -34,7 +34,6 @@ require_relative 'device/orientation'
|
|
34
34
|
# The following files have selenium-webdriver related stuff.
|
35
35
|
require_relative 'base/driver'
|
36
36
|
require_relative 'base/bridge'
|
37
|
-
require_relative 'base/bridge/mjsonwp'
|
38
37
|
require_relative 'base/bridge/w3c'
|
39
38
|
require_relative 'base/capabilities'
|
40
39
|
require_relative 'base/http_default'
|
@@ -16,52 +16,16 @@ module Appium
|
|
16
16
|
module Core
|
17
17
|
class Base
|
18
18
|
class Bridge < ::Selenium::WebDriver::Remote::Bridge
|
19
|
+
# TODO: Move W3C module to here
|
20
|
+
|
19
21
|
# Prefix for extra capability defined by W3C
|
20
22
|
APPIUM_PREFIX = 'appium:'
|
21
23
|
|
22
|
-
# TODO: Remove the forceMjsonwp after Appium server won't need it
|
23
|
-
FORCE_MJSONWP = :forceMjsonwp
|
24
|
-
|
25
|
-
# Almost same as self.handshake in ::Selenium::WebDriver::Remote::Bridge
|
26
|
-
#
|
27
|
-
# Implements protocol handshake which:
|
28
|
-
#
|
29
|
-
# 1. Creates session with driver.
|
30
|
-
# 2. Sniffs response.
|
31
|
-
# 3. Based on the response, understands which dialect we should use.
|
32
|
-
#
|
33
|
-
# @return [Bridge::MJSONWP, Bridge::W3C]
|
34
|
-
#
|
35
|
-
def self.handshake(**opts)
|
36
|
-
desired_capabilities = opts.delete(:desired_capabilities) { ::Selenium::WebDriver::Remote::Capabilities.new }
|
37
|
-
|
38
|
-
if desired_capabilities.is_a?(Symbol)
|
39
|
-
unless ::Selenium::WebDriver::Remote::Capabilities.respond_to?(desired_capabilities)
|
40
|
-
raise ::Selenium::WebDriver::Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}"
|
41
|
-
end
|
42
|
-
|
43
|
-
desired_capabilities = ::Selenium::WebDriver::Remote::Capabilities.__send__(desired_capabilities)
|
44
|
-
end
|
45
|
-
|
46
|
-
bridge = new(opts)
|
47
|
-
capabilities = bridge.create_session(desired_capabilities)
|
48
|
-
|
49
|
-
case bridge.dialect
|
50
|
-
when :oss # for MJSONWP
|
51
|
-
Bridge::MJSONWP.new(capabilities, bridge.session_id, **opts)
|
52
|
-
when :w3c
|
53
|
-
Bridge::W3C.new(capabilities, bridge.session_id, **opts)
|
54
|
-
else
|
55
|
-
raise CoreError, 'cannot understand dialect'
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
24
|
# Override
|
60
25
|
# Creates session handling both OSS and W3C dialects.
|
61
|
-
# Copy from Selenium::WebDriver::Remote::Bridge to keep using +merged_capabilities+ for Appium
|
62
26
|
#
|
63
|
-
# @param [::Selenium::WebDriver::Remote::
|
64
|
-
# @return [::Selenium::WebDriver::Remote::Capabilities
|
27
|
+
# @param [::Selenium::WebDriver::Remote::Capabilities, Hash] desired_capabilities A capability
|
28
|
+
# @return [::Selenium::WebDriver::Remote::Capabilities]
|
65
29
|
#
|
66
30
|
# @example
|
67
31
|
#
|
@@ -79,37 +43,27 @@ module Appium
|
|
79
43
|
# }
|
80
44
|
# }
|
81
45
|
# core = ::Appium::Core.for(caps)
|
82
|
-
# driver = core.start_driver
|
46
|
+
# driver = core.start_driver
|
83
47
|
#
|
84
48
|
def create_session(desired_capabilities)
|
85
|
-
|
49
|
+
caps = add_appium_prefix(desired_capabilities)
|
50
|
+
response = execute(:new_session, {}, { capabilities: { firstMatch: [caps] } })
|
86
51
|
|
87
52
|
@session_id = response['sessionId']
|
88
|
-
|
89
|
-
value = response['value']
|
90
|
-
|
91
|
-
if value.is_a?(Hash) # include for W3C format
|
92
|
-
@session_id = value['sessionId'] if value.key?('sessionId')
|
93
|
-
|
94
|
-
if value.key?('capabilities')
|
95
|
-
value = value['capabilities']
|
96
|
-
elsif value.key?('value')
|
97
|
-
value = value['value']
|
98
|
-
end
|
99
|
-
end
|
53
|
+
capabilities = response['capabilities']
|
100
54
|
|
101
55
|
raise ::Selenium::WebDriver::Error::WebDriverError, 'no sessionId in returned payload' unless @session_id
|
102
56
|
|
103
|
-
json_create(
|
57
|
+
@capabilities = json_create(capabilities)
|
104
58
|
end
|
105
59
|
|
106
60
|
# Append +appium:+ prefix for Appium following W3C spec
|
107
61
|
# https://www.w3.org/TR/webdriver/#dfn-validate-capabilities
|
108
62
|
#
|
109
|
-
# @param [::Selenium::WebDriver::Remote::
|
110
|
-
# @return [::Selenium::WebDriver::Remote::
|
63
|
+
# @param [::Selenium::WebDriver::Remote::Capabilities, Hash] capabilities A capability
|
64
|
+
# @return [::Selenium::WebDriver::Remote::Capabilities]
|
111
65
|
def add_appium_prefix(capabilities)
|
112
|
-
w3c_capabilities = ::Selenium::WebDriver::Remote::
|
66
|
+
w3c_capabilities = ::Selenium::WebDriver::Remote::Capabilities.new
|
113
67
|
|
114
68
|
capabilities = capabilities.__send__(:capabilities) unless capabilities.is_a?(Hash)
|
115
69
|
|
@@ -133,56 +87,17 @@ module Appium
|
|
133
87
|
end
|
134
88
|
|
135
89
|
def extension_prefix?(capability_name)
|
136
|
-
snake_cased_capability_names = ::Selenium::WebDriver::Remote::
|
90
|
+
snake_cased_capability_names = ::Selenium::WebDriver::Remote::Capabilities::KNOWN.map(&:to_s)
|
137
91
|
camel_cased_capability_names = snake_cased_capability_names.map { |v| camel_case(v) }
|
138
92
|
|
93
|
+
# Check 'EXTENSION_CAPABILITY_PATTERN'
|
139
94
|
snake_cased_capability_names.include?(capability_name) ||
|
140
95
|
camel_cased_capability_names.include?(capability_name) ||
|
141
|
-
capability_name.match(
|
96
|
+
capability_name.match(':')
|
142
97
|
end
|
143
98
|
|
144
|
-
def json_create(
|
145
|
-
|
146
|
-
::Selenium::WebDriver.logger.info 'Detected OSS dialect.'
|
147
|
-
@dialect = :oss
|
148
|
-
::Selenium::WebDriver::Remote::Capabilities.json_create(value)
|
149
|
-
else
|
150
|
-
::Selenium::WebDriver.logger.info 'Detected W3C dialect.'
|
151
|
-
@dialect = :w3c
|
152
|
-
::Selenium::WebDriver::Remote::W3C::Capabilities.json_create(value)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def delete_force_mjsonwp(capabilities)
|
157
|
-
w3c_capabilities = ::Selenium::WebDriver::Remote::W3C::Capabilities.new
|
158
|
-
|
159
|
-
capabilities = capabilities.__send__(:capabilities) unless capabilities.is_a?(Hash)
|
160
|
-
capabilities.each do |name, value|
|
161
|
-
next if value.nil?
|
162
|
-
next if value.is_a?(String) && value.empty?
|
163
|
-
next if name == FORCE_MJSONWP
|
164
|
-
|
165
|
-
w3c_capabilities[name] = value
|
166
|
-
end
|
167
|
-
|
168
|
-
w3c_capabilities
|
169
|
-
end
|
170
|
-
|
171
|
-
def merged_capabilities(desired_capabilities)
|
172
|
-
force_mjsonwp = desired_capabilities[FORCE_MJSONWP]
|
173
|
-
desired_capabilities = delete_force_mjsonwp(desired_capabilities) unless force_mjsonwp.nil?
|
174
|
-
|
175
|
-
::Appium::Logger.warn "'forceMjsonwp' no longer works. Sending both W3C and MJSONWP capabilities" if force_mjsonwp
|
176
|
-
|
177
|
-
new_caps = add_appium_prefix(desired_capabilities)
|
178
|
-
w3c_capabilities = ::Selenium::WebDriver::Remote::W3C::Capabilities.from_oss(new_caps)
|
179
|
-
|
180
|
-
{
|
181
|
-
desiredCapabilities: desired_capabilities,
|
182
|
-
capabilities: {
|
183
|
-
firstMatch: [w3c_capabilities]
|
184
|
-
}
|
185
|
-
}
|
99
|
+
def json_create(value)
|
100
|
+
::Selenium::WebDriver::Remote::Capabilities.json_create(value)
|
186
101
|
end
|
187
102
|
end # class Bridge
|
188
103
|
end # class Base
|
@@ -16,7 +16,7 @@ module Appium
|
|
16
16
|
module Core
|
17
17
|
class Base
|
18
18
|
class Bridge
|
19
|
-
class W3C < ::Selenium::WebDriver::Remote::
|
19
|
+
class W3C < ::Selenium::WebDriver::Remote::Bridge
|
20
20
|
include Device::DeviceLock
|
21
21
|
include Device::Keyboard
|
22
22
|
include Device::ImeActions
|
@@ -34,6 +34,106 @@ module Appium
|
|
34
34
|
include Device::ExecuteDriver
|
35
35
|
include Device::Orientation
|
36
36
|
|
37
|
+
# TODO: For compatibility. Should remove.
|
38
|
+
def dialect
|
39
|
+
:w3c
|
40
|
+
end
|
41
|
+
|
42
|
+
# TODO: fixme
|
43
|
+
def browser
|
44
|
+
@browser ||= begin
|
45
|
+
name = @capabilities.browser_name
|
46
|
+
name ? name.tr(' ', '_').downcase.to_sym : 'unknown'
|
47
|
+
rescue KeyError
|
48
|
+
'unknown'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Prefix for extra capability defined by W3C
|
53
|
+
APPIUM_PREFIX = 'appium:'
|
54
|
+
|
55
|
+
# Override
|
56
|
+
# Creates session handling both OSS and W3C dialects.
|
57
|
+
#
|
58
|
+
# @param [::Selenium::WebDriver::Remote::Capabilities, Hash] desired_capabilities A capability
|
59
|
+
# @return [::Selenium::WebDriver::Remote::Capabilities]
|
60
|
+
#
|
61
|
+
# @example
|
62
|
+
#
|
63
|
+
# opts = {
|
64
|
+
# caps: {
|
65
|
+
# platformName: :ios,
|
66
|
+
# automationName: 'XCUITest',
|
67
|
+
# app: 'test/functional/app/UICatalog.app.zip',
|
68
|
+
# platformVersion: '11.4',
|
69
|
+
# deviceName: 'iPhone Simulator',
|
70
|
+
# useNewWDA: true,
|
71
|
+
# },
|
72
|
+
# appium_lib: {
|
73
|
+
# wait: 30
|
74
|
+
# }
|
75
|
+
# }
|
76
|
+
# core = ::Appium::Core.for(caps)
|
77
|
+
# driver = core.start_driver #=> driver.dialect == :w3c if the Appium server support W3C.
|
78
|
+
#
|
79
|
+
def create_session(desired_capabilities)
|
80
|
+
caps = add_appium_prefix(desired_capabilities)
|
81
|
+
response = execute(:new_session, {}, { capabilities: { firstMatch: [caps] } })
|
82
|
+
|
83
|
+
@session_id = response['sessionId']
|
84
|
+
capabilities = response['capabilities']
|
85
|
+
|
86
|
+
raise ::Selenium::WebDriver::Error::WebDriverError, 'no sessionId in returned payload' unless @session_id
|
87
|
+
|
88
|
+
@capabilities = json_create(capabilities)
|
89
|
+
end
|
90
|
+
|
91
|
+
# Append +appium:+ prefix for Appium following W3C spec
|
92
|
+
# https://www.w3.org/TR/webdriver/#dfn-validate-capabilities
|
93
|
+
#
|
94
|
+
# @param [::Selenium::WebDriver::Remote::Capabilities, Hash] capabilities A capability
|
95
|
+
# @return [::Selenium::WebDriver::Remote::Capabilities]
|
96
|
+
def add_appium_prefix(capabilities)
|
97
|
+
w3c_capabilities = ::Selenium::WebDriver::Remote::Capabilities.new
|
98
|
+
|
99
|
+
capabilities = capabilities.__send__(:capabilities) unless capabilities.is_a?(Hash)
|
100
|
+
|
101
|
+
capabilities.each do |name, value|
|
102
|
+
next if value.nil?
|
103
|
+
next if value.is_a?(String) && value.empty?
|
104
|
+
|
105
|
+
capability_name = name.to_s
|
106
|
+
w3c_name = extension_prefix?(capability_name) ? name : "#{APPIUM_PREFIX}#{capability_name}"
|
107
|
+
|
108
|
+
w3c_capabilities[w3c_name] = value
|
109
|
+
end
|
110
|
+
|
111
|
+
w3c_capabilities
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def camel_case(str)
|
117
|
+
str.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
118
|
+
end
|
119
|
+
|
120
|
+
def extension_prefix?(capability_name)
|
121
|
+
snake_cased_capability_names = ::Selenium::WebDriver::Remote::Capabilities::KNOWN.map(&:to_s)
|
122
|
+
camel_cased_capability_names = snake_cased_capability_names.map { |v| camel_case(v) }
|
123
|
+
|
124
|
+
# Check 'EXTENSION_CAPABILITY_PATTERN'
|
125
|
+
snake_cased_capability_names.include?(capability_name) ||
|
126
|
+
camel_cased_capability_names.include?(capability_name) ||
|
127
|
+
capability_name.match(':')
|
128
|
+
end
|
129
|
+
|
130
|
+
def json_create(value)
|
131
|
+
@dialect = :w3c
|
132
|
+
::Selenium::WebDriver::Remote::Capabilities.json_create(value)
|
133
|
+
end
|
134
|
+
|
135
|
+
public
|
136
|
+
|
37
137
|
def commands(command)
|
38
138
|
::Appium::Core::Commands::W3C::COMMANDS[command]
|
39
139
|
end
|
@@ -76,7 +176,7 @@ module Appium
|
|
76
176
|
|
77
177
|
# Port from MJSONWP
|
78
178
|
def session_capabilities
|
79
|
-
::Selenium::WebDriver::Remote::
|
179
|
+
::Selenium::WebDriver::Remote::Capabilities.json_create execute(:get_capabilities)
|
80
180
|
end
|
81
181
|
|
82
182
|
# Port from MJSONWP
|
@@ -19,10 +19,10 @@ module Appium
|
|
19
19
|
# @private
|
20
20
|
# @param [Hash] opts_caps Capabilities for Appium server. All capability keys are converted to lowerCamelCase when
|
21
21
|
# this client sends capabilities to Appium server as JSON format.
|
22
|
-
# @return [::Selenium::WebDriver::Remote::
|
23
|
-
# inherited ::Selenium::WebDriver::Remote::
|
22
|
+
# @return [::Selenium::WebDriver::Remote::Capabilities] Return instance of Appium::Core::Base::Capabilities
|
23
|
+
# inherited ::Selenium::WebDriver::Remote::Capabilities
|
24
24
|
def self.create_capabilities(opts_caps = {})
|
25
|
-
::Selenium::WebDriver::Remote::
|
25
|
+
::Selenium::WebDriver::Remote::Capabilities.new(opts_caps)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -16,8 +16,129 @@ module Appium
|
|
16
16
|
module Core
|
17
17
|
class Base
|
18
18
|
module Commands
|
19
|
-
|
20
|
-
|
19
|
+
W3C = {
|
20
|
+
status: [:get, 'status'],
|
21
|
+
|
22
|
+
#
|
23
|
+
# session handling
|
24
|
+
#
|
25
|
+
|
26
|
+
new_session: [:post, 'session'],
|
27
|
+
delete_session: [:delete, 'session/:session_id'],
|
28
|
+
|
29
|
+
#
|
30
|
+
# basic driver
|
31
|
+
#
|
32
|
+
|
33
|
+
get: [:post, 'session/:session_id/url'],
|
34
|
+
get_current_url: [:get, 'session/:session_id/url'],
|
35
|
+
back: [:post, 'session/:session_id/back'],
|
36
|
+
forward: [:post, 'session/:session_id/forward'],
|
37
|
+
refresh: [:post, 'session/:session_id/refresh'],
|
38
|
+
get_title: [:get, 'session/:session_id/title'],
|
39
|
+
|
40
|
+
#
|
41
|
+
# window and Frame handling
|
42
|
+
#
|
43
|
+
|
44
|
+
get_window_handle: [:get, 'session/:session_id/window'],
|
45
|
+
new_window: [:post, 'session/:session_id/window/new'],
|
46
|
+
close_window: [:delete, 'session/:session_id/window'],
|
47
|
+
switch_to_window: [:post, 'session/:session_id/window'],
|
48
|
+
get_window_handles: [:get, 'session/:session_id/window/handles'],
|
49
|
+
fullscreen_window: [:post, 'session/:session_id/window/fullscreen'],
|
50
|
+
minimize_window: [:post, 'session/:session_id/window/minimize'],
|
51
|
+
maximize_window: [:post, 'session/:session_id/window/maximize'],
|
52
|
+
set_window_size: [:post, 'session/:session_id/window/size'],
|
53
|
+
get_window_size: [:get, 'session/:session_id/window/size'],
|
54
|
+
set_window_position: [:post, 'session/:session_id/window/position'],
|
55
|
+
get_window_position: [:get, 'session/:session_id/window/position'],
|
56
|
+
set_window_rect: [:post, 'session/:session_id/window/rect'],
|
57
|
+
get_window_rect: [:get, 'session/:session_id/window/rect'],
|
58
|
+
switch_to_frame: [:post, 'session/:session_id/frame'],
|
59
|
+
switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'],
|
60
|
+
|
61
|
+
#
|
62
|
+
# element
|
63
|
+
#
|
64
|
+
|
65
|
+
find_element: [:post, 'session/:session_id/element'],
|
66
|
+
find_elements: [:post, 'session/:session_id/elements'],
|
67
|
+
find_child_element: [:post, 'session/:session_id/element/:id/element'],
|
68
|
+
find_child_elements: [:post, 'session/:session_id/element/:id/elements'],
|
69
|
+
get_active_element: [:get, 'session/:session_id/element/active'],
|
70
|
+
is_element_selected: [:get, 'session/:session_id/element/:id/selected'],
|
71
|
+
get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'],
|
72
|
+
get_element_property: [:get, 'session/:session_id/element/:id/property/:name'],
|
73
|
+
get_element_css_value: [:get, 'session/:session_id/element/:id/css/:property_name'],
|
74
|
+
get_element_text: [:get, 'session/:session_id/element/:id/text'],
|
75
|
+
get_element_tag_name: [:get, 'session/:session_id/element/:id/name'],
|
76
|
+
get_element_rect: [:get, 'session/:session_id/element/:id/rect'],
|
77
|
+
is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'],
|
78
|
+
|
79
|
+
#
|
80
|
+
# document handling
|
81
|
+
#
|
82
|
+
|
83
|
+
get_page_source: [:get, 'session/:session_id/source'],
|
84
|
+
execute_script: [:post, 'session/:session_id/execute/sync'],
|
85
|
+
execute_async_script: [:post, 'session/:session_id/execute/async'],
|
86
|
+
|
87
|
+
#
|
88
|
+
# cookies
|
89
|
+
#
|
90
|
+
|
91
|
+
get_all_cookies: [:get, 'session/:session_id/cookie'],
|
92
|
+
get_cookie: [:get, 'session/:session_id/cookie/:name'],
|
93
|
+
add_cookie: [:post, 'session/:session_id/cookie'],
|
94
|
+
delete_cookie: [:delete, 'session/:session_id/cookie/:name'],
|
95
|
+
delete_all_cookies: [:delete, 'session/:session_id/cookie'],
|
96
|
+
|
97
|
+
#
|
98
|
+
# timeouts
|
99
|
+
#
|
100
|
+
|
101
|
+
set_timeout: [:post, 'session/:session_id/timeouts'],
|
102
|
+
|
103
|
+
#
|
104
|
+
# actions
|
105
|
+
#
|
106
|
+
|
107
|
+
actions: [:post, 'session/:session_id/actions'],
|
108
|
+
release_actions: [:delete, 'session/:session_id/actions'],
|
109
|
+
print_page: [:post, 'session/:session_id/print'],
|
110
|
+
|
111
|
+
#
|
112
|
+
# Element Operations
|
113
|
+
#
|
114
|
+
|
115
|
+
element_click: [:post, 'session/:session_id/element/:id/click'],
|
116
|
+
element_tap: [:post, 'session/:session_id/element/:id/tap'],
|
117
|
+
element_clear: [:post, 'session/:session_id/element/:id/clear'],
|
118
|
+
element_send_keys: [:post, 'session/:session_id/element/:id/value'],
|
119
|
+
|
120
|
+
#
|
121
|
+
# alerts
|
122
|
+
#
|
123
|
+
|
124
|
+
dismiss_alert: [:post, 'session/:session_id/alert/dismiss'],
|
125
|
+
accept_alert: [:post, 'session/:session_id/alert/accept'],
|
126
|
+
get_alert_text: [:get, 'session/:session_id/alert/text'],
|
127
|
+
send_alert_text: [:post, 'session/:session_id/alert/text'],
|
128
|
+
|
129
|
+
#
|
130
|
+
# screenshot
|
131
|
+
#
|
132
|
+
|
133
|
+
take_screenshot: [:get, 'session/:session_id/screenshot'],
|
134
|
+
take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot'],
|
135
|
+
|
136
|
+
#
|
137
|
+
# server extensions
|
138
|
+
#
|
139
|
+
|
140
|
+
upload_file: [:post, 'session/:session_id/se/file']
|
141
|
+
}.freeze
|
21
142
|
end # module Commands
|
22
143
|
end # module Base
|
23
144
|
end # module Core
|
@@ -18,6 +18,7 @@ require_relative 'screenshot'
|
|
18
18
|
require_relative 'rotable'
|
19
19
|
require_relative 'remote_status'
|
20
20
|
require_relative 'has_location'
|
21
|
+
require_relative 'has_network_connection'
|
21
22
|
|
22
23
|
module Appium
|
23
24
|
module Core
|
@@ -27,23 +28,55 @@ module Appium
|
|
27
28
|
include ::Selenium::WebDriver::DriverExtensions::HasSessionId
|
28
29
|
include ::Selenium::WebDriver::DriverExtensions::HasRemoteStatus
|
29
30
|
include ::Selenium::WebDriver::DriverExtensions::HasWebStorage
|
30
|
-
include ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection
|
31
|
-
include ::Selenium::WebDriver::DriverExtensions::HasTouchScreen
|
32
31
|
|
33
32
|
include ::Appium::Core::Base::Rotatable
|
34
33
|
include ::Appium::Core::Base::SearchContext
|
35
34
|
include ::Appium::Core::Base::TakesScreenshot
|
36
35
|
include ::Appium::Core::Base::HasRemoteStatus
|
37
36
|
include ::Appium::Core::Base::HasLocation
|
37
|
+
include ::Appium::Core::Base::HasNetworkConnection
|
38
38
|
|
39
39
|
# Private API.
|
40
40
|
# Do not use this for general use. Used by flutter driver to get bridge for creating a new element
|
41
41
|
attr_reader :bridge
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
# Almost same as self.handshake in ::Selenium::WebDriver::Remote::Bridge
|
44
|
+
#
|
45
|
+
# Implements protocol handshake which:
|
46
|
+
#
|
47
|
+
# 1. Creates session with driver.
|
48
|
+
# 2. Sniffs response.
|
49
|
+
# 3. Based on the response, understands which dialect we should use.
|
50
|
+
#
|
51
|
+
# @return [Bridge::W3C]
|
52
|
+
#
|
53
|
+
# TODO: Fixme
|
54
|
+
def create_bridge(**opts)
|
55
|
+
opts[:url] ||= service_url(opts)
|
56
|
+
caps = opts.delete(:capabilities)
|
57
|
+
# NOTE: This is deprecated
|
58
|
+
cap_array = caps.is_a?(Hash) ? [caps] : Array(caps)
|
59
|
+
|
60
|
+
desired_capabilities = opts.delete(:desired_capabilities)
|
61
|
+
if desired_capabilities
|
62
|
+
if desired_capabilities.is_a?(Hash)
|
63
|
+
desired_capabilities = ::Selenium::WebDriver::Remote::Capabilities(desired_capabilities)
|
64
|
+
end
|
65
|
+
cap_array << desired_capabilities
|
66
|
+
end
|
67
|
+
|
68
|
+
options = opts.delete(:options)
|
69
|
+
cap_array << options if options
|
70
|
+
|
71
|
+
capabilities = generate_capabilities(cap_array)
|
72
|
+
|
73
|
+
bridge_opts = { http_client: opts.delete(:http_client), url: opts.delete(:url) }
|
74
|
+
raise ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
|
75
|
+
|
76
|
+
bridge = ::Appium::Core::Base::Bridge::W3C.new(**bridge_opts)
|
77
|
+
|
78
|
+
bridge.create_session(capabilities)
|
79
|
+
bridge
|
47
80
|
end
|
48
81
|
|
49
82
|
# Get the dialect value
|
@@ -164,10 +197,24 @@ module Appium
|
|
164
197
|
@bridge = bridge
|
165
198
|
end
|
166
199
|
|
200
|
+
# Get appium Settings for current test session.
|
201
|
+
#
|
202
|
+
# @example
|
203
|
+
#
|
204
|
+
# @driver.settings.get
|
205
|
+
#
|
167
206
|
def get
|
168
207
|
@bridge.get_settings
|
169
208
|
end
|
170
209
|
|
210
|
+
# Update Appium Settings for current test session
|
211
|
+
#
|
212
|
+
# @param [Hash] settings Settings to update, keys are settings, values to value to set each setting to
|
213
|
+
#
|
214
|
+
# @example
|
215
|
+
#
|
216
|
+
# @driver.settings.update({'allowInvisibleElements': true})
|
217
|
+
#
|
171
218
|
def update(settings)
|
172
219
|
@bridge.update_settings(settings)
|
173
220
|
end
|
@@ -204,8 +251,8 @@ module Appium
|
|
204
251
|
#
|
205
252
|
# @example
|
206
253
|
#
|
207
|
-
# @driver.update_settings('allowInvisibleElements': true)
|
208
|
-
# @driver.settings.update('allowInvisibleElements': true)
|
254
|
+
# @driver.update_settings({ 'allowInvisibleElements': true })
|
255
|
+
# @driver.settings.update({ 'allowInvisibleElements': true })
|
209
256
|
# @driver.settings = { 'allowInvisibleElements': true }
|
210
257
|
#
|
211
258
|
def settings=(value)
|
@@ -887,13 +934,13 @@ module Appium
|
|
887
934
|
# Retrieve the capabilities of the specified session.
|
888
935
|
# It's almost same as +@driver.capabilities+ but you can get more details.
|
889
936
|
#
|
890
|
-
# @return [Selenium::WebDriver::Remote::Capabilities, Selenium::WebDriver::Remote::
|
937
|
+
# @return [Selenium::WebDriver::Remote::Capabilities, Selenium::WebDriver::Remote::Capabilities]
|
891
938
|
#
|
892
939
|
# @example
|
893
940
|
# @driver.session_capabilities
|
894
941
|
#
|
895
942
|
# #=> uiautomator2
|
896
|
-
# # <Selenium::WebDriver::Remote::
|
943
|
+
# # <Selenium::WebDriver::Remote::Capabilities:0x007fa38dae1360
|
897
944
|
# # @capabilities=
|
898
945
|
# # {:proxy=>nil,
|
899
946
|
# # :browser_name=>nil,
|
@@ -943,7 +990,7 @@ module Appium
|
|
943
990
|
# # "viewportRect"=>{"left"=>0, "top"=>63, "width"=>1080, "height"=>1731}}>
|
944
991
|
# #
|
945
992
|
# #=> XCUITest
|
946
|
-
# # <Selenium::WebDriver::Remote::
|
993
|
+
# # <Selenium::WebDriver::Remote::Capabilities:0x007fb15dc01370
|
947
994
|
# # @capabilities=
|
948
995
|
# # {:proxy=>nil,
|
949
996
|
# # :browser_name=>"UICatalog",
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module Appium
|
16
|
+
module Core
|
17
|
+
class Base
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
module HasNetworkConnection
|
22
|
+
def network_connection_type
|
23
|
+
connection_value = @bridge.network_connection
|
24
|
+
|
25
|
+
connection_type = values_to_type[connection_value]
|
26
|
+
|
27
|
+
# In case the connection type is not recognized return the
|
28
|
+
# connection value.
|
29
|
+
connection_type || connection_value
|
30
|
+
end
|
31
|
+
|
32
|
+
def network_connection_type=(connection_type)
|
33
|
+
raise ArgumentError, 'Invalid connection type' unless valid_type? connection_type
|
34
|
+
|
35
|
+
connection_value = type_to_values[connection_type]
|
36
|
+
|
37
|
+
@bridge.network_connection = connection_value
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def type_to_values
|
43
|
+
{ airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0 }
|
44
|
+
end
|
45
|
+
|
46
|
+
def values_to_type
|
47
|
+
type_to_values.invert
|
48
|
+
end
|
49
|
+
|
50
|
+
def valid_type?(type)
|
51
|
+
type_to_values.keys.include? type
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -79,10 +79,6 @@ module Appium
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def create_bridge_command(method, &block)
|
82
|
-
::Appium::Core::Base::Bridge::MJSONWP.class_eval do
|
83
|
-
undef_method method if method_defined? method
|
84
|
-
block_given? ? class_eval(&block) : define_method(method) { execute method }
|
85
|
-
end
|
86
82
|
::Appium::Core::Base::Bridge::W3C.class_eval do
|
87
83
|
undef_method method if method_defined? method
|
88
84
|
block_given? ? class_eval(&block) : define_method(method) { execute method }
|
@@ -368,10 +368,10 @@ module Appium
|
|
368
368
|
|
369
369
|
begin
|
370
370
|
# included https://github.com/SeleniumHQ/selenium/blob/43f8b3f66e7e01124eff6a5805269ee441f65707/rb/lib/selenium/webdriver/remote/driver.rb#L29
|
371
|
-
@driver = ::Appium::Core::Base::Driver.new(
|
372
|
-
|
373
|
-
|
374
|
-
|
371
|
+
@driver = ::Appium::Core::Base::Driver.new(listener: @listener,
|
372
|
+
http_client: @http_client,
|
373
|
+
desired_capabilities: @caps,
|
374
|
+
url: @custom_url)
|
375
375
|
|
376
376
|
if @direct_connect
|
377
377
|
d_c = DirectConnections.new(@driver.capabilities)
|
@@ -14,7 +14,7 @@
|
|
14
14
|
|
15
15
|
module Appium
|
16
16
|
module Core
|
17
|
-
VERSION = '
|
18
|
-
DATE = '2021-03-
|
17
|
+
VERSION = '5.0.0.beta1' unless defined? ::Appium::Core::VERSION
|
18
|
+
DATE = '2021-03-21' unless defined? ::Appium::Core::DATE
|
19
19
|
end
|
20
20
|
end
|
data/script/commands.rb
CHANGED
@@ -18,25 +18,21 @@ require './lib/appium_lib_core'
|
|
18
18
|
module Script
|
19
19
|
class CommandsChecker
|
20
20
|
attr_reader :spec_commands,
|
21
|
-
:
|
22
|
-
:
|
21
|
+
:implemented_w3c_commands, :implemented_core_commands,
|
22
|
+
:webdriver_w3c_commands
|
23
23
|
|
24
24
|
# Set commands implemented in this core library.
|
25
25
|
#
|
26
|
-
# - implemented_mjsonwp_commands: All commands include ::Selenium::WebDriver::Remote::OSS::Bridge::COMMANDS
|
27
26
|
# - implemented_w3c_commands: All commands include ::Selenium::WebDriver::Remote::W3C::Bridge::COMMANDS
|
28
27
|
# - implemented_core_commands: All commands except for selenium-webdriver's commands
|
29
|
-
# - webdriver_oss_commands: ::Selenium::WebDriver::Remote::OSS::Bridge::COMMANDS
|
30
28
|
# - webdriver_w3c_commands: ::Selenium::WebDriver::Remote::W3C::Bridge::COMMANDS
|
31
29
|
#
|
32
30
|
def initialize
|
33
31
|
@spec_commands = nil
|
34
32
|
|
35
|
-
@implemented_mjsonwp_commands = convert_driver_commands Appium::Core::Commands::MJSONWP::COMMANDS
|
36
33
|
@implemented_w3c_commands = convert_driver_commands Appium::Core::Commands::W3C::COMMANDS
|
37
34
|
@implemented_core_commands = convert_driver_commands Appium::Core::Commands::COMMANDS
|
38
35
|
|
39
|
-
@webdriver_oss_commands = convert_driver_commands Appium::Core::Base::Commands::OSS
|
40
36
|
@webdriver_w3c_commands = convert_driver_commands Appium::Core::Base::Commands::W3C
|
41
37
|
end
|
42
38
|
|
@@ -80,18 +76,6 @@ module Script
|
|
80
76
|
end
|
81
77
|
end
|
82
78
|
|
83
|
-
# All commands which haven't been implemented in ruby core library yet.
|
84
|
-
# @return [Hash]
|
85
|
-
#
|
86
|
-
def all_diff_commands_mjsonwp
|
87
|
-
result = compare_commands(@spec_commands, @implemented_mjsonwp_commands)
|
88
|
-
|
89
|
-
white_list.each { |v| result.delete v }
|
90
|
-
w3c_spec.each { |v| result.delete v }
|
91
|
-
|
92
|
-
result
|
93
|
-
end
|
94
|
-
|
95
79
|
# All commands which haven't been implemented in ruby core library yet.
|
96
80
|
# @return [Hash]
|
97
81
|
#
|
@@ -111,13 +95,6 @@ module Script
|
|
111
95
|
result
|
112
96
|
end
|
113
97
|
|
114
|
-
def diff_webdriver_oss
|
115
|
-
result = compare_commands(@spec_commands, @webdriver_oss_commands)
|
116
|
-
white_list.each { |v| result.delete v }
|
117
|
-
w3c_spec.each { |v| result.delete v }
|
118
|
-
result
|
119
|
-
end
|
120
|
-
|
121
98
|
def diff_webdriver_w3c
|
122
99
|
result = compare_commands(@spec_commands, @webdriver_w3c_commands)
|
123
100
|
white_list.each { |v| result.delete v }
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appium_lib_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuaki MATSUO
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.14'
|
20
|
-
- - ">="
|
17
|
+
- - '='
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: 4.0.0.beta2
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.14'
|
30
|
-
- - ">="
|
24
|
+
- - '='
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
26
|
+
version: 4.0.0.beta2
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: faye-websocket
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,28 +114,28 @@ dependencies:
|
|
120
114
|
requirements:
|
121
115
|
- - "~>"
|
122
116
|
- !ruby/object:Gem::Version
|
123
|
-
version: 3.
|
117
|
+
version: 3.12.1
|
124
118
|
type: :development
|
125
119
|
prerelease: false
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
127
121
|
requirements:
|
128
122
|
- - "~>"
|
129
123
|
- !ruby/object:Gem::Version
|
130
|
-
version: 3.
|
124
|
+
version: 3.12.1
|
131
125
|
- !ruby/object:Gem::Dependency
|
132
126
|
name: rubocop
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
129
|
- - '='
|
136
130
|
- !ruby/object:Gem::Version
|
137
|
-
version: 1.
|
131
|
+
version: 1.11.0
|
138
132
|
type: :development
|
139
133
|
prerelease: false
|
140
134
|
version_requirements: !ruby/object:Gem::Requirement
|
141
135
|
requirements:
|
142
136
|
- - '='
|
143
137
|
- !ruby/object:Gem::Version
|
144
|
-
version: 1.
|
138
|
+
version: 1.11.0
|
145
139
|
- !ruby/object:Gem::Dependency
|
146
140
|
name: appium_thor
|
147
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,12 +256,12 @@ files:
|
|
262
256
|
- lib/appium_lib_core/common.rb
|
263
257
|
- lib/appium_lib_core/common/base.rb
|
264
258
|
- lib/appium_lib_core/common/base/bridge.rb
|
265
|
-
- lib/appium_lib_core/common/base/bridge/mjsonwp.rb
|
266
259
|
- lib/appium_lib_core/common/base/bridge/w3c.rb
|
267
260
|
- lib/appium_lib_core/common/base/capabilities.rb
|
268
261
|
- lib/appium_lib_core/common/base/command.rb
|
269
262
|
- lib/appium_lib_core/common/base/driver.rb
|
270
263
|
- lib/appium_lib_core/common/base/has_location.rb
|
264
|
+
- lib/appium_lib_core/common/base/has_network_connection.rb
|
271
265
|
- lib/appium_lib_core/common/base/http_default.rb
|
272
266
|
- lib/appium_lib_core/common/base/platform.rb
|
273
267
|
- lib/appium_lib_core/common/base/remote_status.rb
|
@@ -276,7 +270,6 @@ files:
|
|
276
270
|
- lib/appium_lib_core/common/base/search_context.rb
|
277
271
|
- lib/appium_lib_core/common/command.rb
|
278
272
|
- lib/appium_lib_core/common/command/common.rb
|
279
|
-
- lib/appium_lib_core/common/command/mjsonwp.rb
|
280
273
|
- lib/appium_lib_core/common/command/w3c.rb
|
281
274
|
- lib/appium_lib_core/common/device/app_management.rb
|
282
275
|
- lib/appium_lib_core/common/device/app_state.rb
|
@@ -342,12 +335,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
342
335
|
requirements:
|
343
336
|
- - ">="
|
344
337
|
- !ruby/object:Gem::Version
|
345
|
-
version: '2.
|
338
|
+
version: '2.5'
|
346
339
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
347
340
|
requirements:
|
348
|
-
- - "
|
341
|
+
- - ">"
|
349
342
|
- !ruby/object:Gem::Version
|
350
|
-
version:
|
343
|
+
version: 1.3.1
|
351
344
|
requirements: []
|
352
345
|
rubygems_version: 3.1.2
|
353
346
|
signing_key:
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module Appium
|
16
|
-
module Core
|
17
|
-
class Base
|
18
|
-
class Bridge
|
19
|
-
class MJSONWP < ::Selenium::WebDriver::Remote::OSS::Bridge
|
20
|
-
include Device::DeviceLock
|
21
|
-
include Device::Keyboard
|
22
|
-
include Device::ImeActions
|
23
|
-
include Device::Setting
|
24
|
-
include Device::Context
|
25
|
-
include Device::Value
|
26
|
-
include Device::FileManagement
|
27
|
-
include Device::KeyEvent
|
28
|
-
include Device::ImageComparison
|
29
|
-
include Device::AppManagement
|
30
|
-
include Device::AppState
|
31
|
-
include Device::ScreenRecord::Command
|
32
|
-
include Device::Device
|
33
|
-
include Device::TouchActions
|
34
|
-
include Device::ExecuteDriver
|
35
|
-
|
36
|
-
def commands(command)
|
37
|
-
::Appium::Core::Commands::MJSONWP::COMMANDS[command]
|
38
|
-
end
|
39
|
-
|
40
|
-
# Returns all available sessions on the Appium server instance
|
41
|
-
def sessions
|
42
|
-
execute :get_all_sessions
|
43
|
-
end
|
44
|
-
|
45
|
-
def status
|
46
|
-
execute :status
|
47
|
-
end
|
48
|
-
|
49
|
-
# For Appium
|
50
|
-
def log_event(vendor, event)
|
51
|
-
execute :post_log_event, {}, { vendor: vendor, event: event }
|
52
|
-
end
|
53
|
-
|
54
|
-
# For Appium
|
55
|
-
def log_events(type = nil)
|
56
|
-
args = {}
|
57
|
-
args['type'] = type unless type.nil?
|
58
|
-
|
59
|
-
execute :get_log_events, {}, args
|
60
|
-
end
|
61
|
-
|
62
|
-
def take_element_screenshot(element)
|
63
|
-
execute :take_element_screenshot, id: element.ref
|
64
|
-
end
|
65
|
-
|
66
|
-
def take_viewport_screenshot
|
67
|
-
# TODO: this hasn't been supported by Espresso driver
|
68
|
-
execute_script('mobile: viewportScreenshot')
|
69
|
-
end
|
70
|
-
|
71
|
-
def send_actions(_data)
|
72
|
-
raise Error::UnsupportedOperationError, '#send_actions has not been supported in MJSONWP'
|
73
|
-
end
|
74
|
-
|
75
|
-
# For Appium
|
76
|
-
# @param [Hash] id The id which can get as a response from server
|
77
|
-
# @return [::Selenium::WebDriver::Element]
|
78
|
-
def convert_to_element(id)
|
79
|
-
::Selenium::WebDriver::Element.new self, element_id_from(id)
|
80
|
-
end
|
81
|
-
|
82
|
-
def set_location(lat, lon, alt = 0.0, speed: nil)
|
83
|
-
loc = { latitude: lat, longitude: lon, altitude: alt }
|
84
|
-
loc[:speed] = speed unless speed.nil?
|
85
|
-
execute :set_location, {}, { location: loc }
|
86
|
-
end
|
87
|
-
end # class MJSONWP
|
88
|
-
end # class Bridge
|
89
|
-
end # class Base
|
90
|
-
end # module Core
|
91
|
-
end # module Appium
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module Appium
|
16
|
-
module Core
|
17
|
-
module Commands
|
18
|
-
module MJSONWP
|
19
|
-
COMMANDS = ::Appium::Core::Commands::COMMANDS.merge(::Appium::Core::Base::Commands::OSS).merge(
|
20
|
-
{
|
21
|
-
# W3C already has.
|
22
|
-
take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot']
|
23
|
-
}
|
24
|
-
).freeze
|
25
|
-
end # module MJSONWP
|
26
|
-
end # module Commands
|
27
|
-
end # module Core
|
28
|
-
end # Appium
|