appium_lib_core 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92864805498c13b3e41df7d6b5ef4fc5965fee0d
4
- data.tar.gz: a911e896fc8fcb342eb8af36e43ee2ba341e2439
3
+ metadata.gz: 44fc100d5d5e9bd6eca0c7710db01c24e6f80c2e
4
+ data.tar.gz: cdba41bed57c4d4f509e39460a273f697f1d19d8
5
5
  SHA512:
6
- metadata.gz: bbc2bceb05631b3b7ee85e5ddccf50bb763e9223cf9a83f2c3653a69250f8da45c20f7ae308f8779c11653a99d58f41fa4fc1ec1b1f611856397a78cbb818455
7
- data.tar.gz: 01a3830df3812f6b0a71f9493ccd18a22dfd0447858978d1f464fa285df75c12e5055d31341c0f2a38f9573dcea2effef409bc2fbe7298f08fa1a58ade694cc7
6
+ metadata.gz: 6ffd78624d5ffec1e6835dbf3f17c6664addc16e6d16ff4b1d58befaa96f0b1b6b0b6a5625cc7be98946858a69c2126e7b264668de458da94df48a03b71219fe
7
+ data.tar.gz: 83e202a1d228ae437a1ae20daecbf94b1a460994e3f6a829374872558a61cdaa1fe0221517945ad331168607f0e71e25aa1ce31863efba945f0037a8dcfb1d24
data/.travis.yml CHANGED
@@ -4,7 +4,12 @@ language: ruby
4
4
  rvm:
5
5
  - 2.2.5
6
6
  - 2.3.3
7
- - 2.4.0
7
+ - 2.4.3
8
+ - 2.5.0
9
+
10
+ before_install:
11
+ - gem update --system
12
+ - gem update bundler
8
13
 
9
14
  script:
10
15
  - bundle exec rake rubocop
data/CHANGELOG.md CHANGED
@@ -5,7 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  ### Enhancements
6
6
 
7
7
  ### Bug fixes
8
- - Fix some w3c methods to work with Appium part 2 [#38](https://github.com/appium/ruby_lib_core/pull/38)
8
+
9
+ ### Deprecations
10
+
11
+ ## [1.2.4] - 2018-01-03
12
+ ### Enhancements
13
+ - Refactor `create_session` in `Appium::Core::Base::Bridge`
14
+ - Be able to communicate with Appium by `W3C` based webdriver protocol if the Appium supports W3C protocol.
15
+ - If `forceMjsonwp: true` exists in the capability, the client try to communicate `mjsonwp` based protocol
16
+ - By default, it depends on the response from the server
17
+ - Read API doc for `Appium::Core::Base::Bridge#create_session` to read the example of `forceMjsonwp`
18
+ - Backport some commands from OSS module to W3C module
19
+ - Read `lib/appium_lib_core/common/base/w3c_bridge.rb` for more details
20
+ - Can get logs like `driver.logs.available_types` and `driver.logs.get`
21
+
22
+ ### Bug fixes
9
23
 
10
24
  ### Deprecations
11
25
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency 'json', '>= 1.8'
27
27
 
28
28
  spec.add_development_dependency 'bundler', '~> 1.14'
29
- spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rake', '~> 12.0'
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'
@@ -53,6 +53,7 @@ module Appium
53
53
  # @example
54
54
  #
55
55
  # @driver.set_network_connection 1
56
+ # @driver.network_connection_type = 1
56
57
  #
57
58
 
58
59
  # @!method get_performance_data_types
@@ -1,8 +1,8 @@
1
1
  # The following files have selenium-webdriver related stuff.
2
2
  require_relative 'base/driver'
3
3
  require_relative 'base/bridge'
4
- require_relative 'base/msjsonwp_bridge'
5
- require_relative 'base/w3c_bridge'
4
+ require_relative 'base/bridge/msjsonwp'
5
+ require_relative 'base/bridge/w3c'
6
6
  require_relative 'base/capabilities'
7
7
  require_relative 'base/http_default'
8
8
  require_relative 'base/search_context'
@@ -2,6 +2,9 @@ module Appium
2
2
  module Core
3
3
  class Base
4
4
  class Bridge < ::Selenium::WebDriver::Remote::Bridge
5
+ # Prefix for extra capability defined by W3C
6
+ APPIUM_PREFIX = 'appium:'.freeze
7
+
5
8
  # Almost same as self.handshake in ::Selenium::WebDriver::Remote::Bridge
6
9
  #
7
10
  # Implements protocol handshake which:
@@ -10,13 +13,13 @@ module Appium
10
13
  # 2. Sniffs response.
11
14
  # 3. Based on the response, understands which dialect we should use.
12
15
  #
13
- # @return [CoreBridgeMJSONWP, CoreBridgeW3C]
16
+ # @return [Bridge::MJSONWP, Bridge::W3C]
14
17
  #
15
18
  def self.handshake(**opts)
16
19
  desired_capabilities = opts.delete(:desired_capabilities)
17
20
 
18
21
  if desired_capabilities.is_a?(Symbol)
19
- unless Remote::Capabilities.respond_to?(desired_capabilities)
22
+ unless ::Selenium::WebDriver::Remote::Capabilities.respond_to?(desired_capabilities)
20
23
  raise Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}"
21
24
  end
22
25
  desired_capabilities = Remote::Capabilities.__send__(desired_capabilities)
@@ -27,14 +30,85 @@ module Appium
27
30
 
28
31
  case bridge.dialect
29
32
  when :oss # for MJSONWP
30
- CoreBridgeMJSONWP.new(capabilities, bridge.session_id, opts)
33
+ Bridge::MJSONWP.new(capabilities, bridge.session_id, opts)
31
34
  when :w3c
32
- CoreBridgeW3C.new(capabilities, bridge.session_id, opts)
35
+ Bridge::W3C.new(capabilities, bridge.session_id, opts)
33
36
  else
34
37
  raise CoreError, 'cannot understand dialect'
35
38
  end
36
39
  end
37
40
 
41
+ # Override
42
+ # Creates session handling both OSS and W3C dialects.
43
+ # Copy from Selenium::WebDriver::Remote::Bridge to keep using `merged_capabilities` for Appium
44
+ #
45
+ # If `desired_capabilities` has `forceMjsonwp: true` in the capability, this bridge works with mjsonwp protocol.
46
+ # If `forceMjsonwp: false` or no the capability, it depends on server side whether this bridge works as w3c or mjsonwp.
47
+ #
48
+ # @param [::Selenium::WebDriver::Remote::W3C::Capabilities, Hash] capabilities A capability
49
+ # @return [::Selenium::WebDriver::Remote::Capabilities, ::Selenium::WebDriver::Remote::W3C::Capabilities]
50
+ #
51
+ # @example
52
+ #
53
+ # opts = {
54
+ # caps: {
55
+ # platformName: :ios,
56
+ # automationName: 'XCUITest',
57
+ # app: 'test/functional/app/UICatalog.app',
58
+ # platformVersion: '10.3',
59
+ # deviceName: 'iPhone Simulator',
60
+ # useNewWDA: true,
61
+ # forceMjsonwp: true
62
+ # },
63
+ # appium_lib: {
64
+ # wait: 30
65
+ # }
66
+ # }
67
+ # core = ::Appium::Core.for(self, caps)
68
+ # driver = core.start_driver #=> driver.dialect == :oss
69
+ #
70
+ # @example
71
+ #
72
+ # opts = {
73
+ # caps: {
74
+ # platformName: :ios,
75
+ # automationName: 'XCUITest',
76
+ # app: 'test/functional/app/UICatalog.app',
77
+ # platformVersion: '10.3',
78
+ # deviceName: 'iPhone Simulator',
79
+ # useNewWDA: true,
80
+ # },
81
+ # appium_lib: {
82
+ # wait: 30
83
+ # }
84
+ # }
85
+ # core = ::Appium::Core.for(self, caps)
86
+ # driver = core.start_driver #=> driver.dialect == :w3c if the Appium server support W3C.
87
+ #
88
+ def create_session(desired_capabilities)
89
+ response = execute(:new_session, {}, merged_capabilities(desired_capabilities))
90
+
91
+ @session_id = response['sessionId']
92
+ oss_status = response['status'] # for compatibility with Appium 1.7.1-
93
+ value = response['value']
94
+
95
+ if value.is_a?(Hash) # include for W3C format
96
+ @session_id = value['sessionId'] if value.key?('sessionId')
97
+
98
+ if value.key?('capabilities')
99
+ value = value['capabilities']
100
+ elsif value.key?('value')
101
+ value = value['value']
102
+ end
103
+ end
104
+
105
+ unless @session_id
106
+ raise Error::WebDriverError, 'no sessionId in returned payload'
107
+ end
108
+
109
+ json_create(oss_status, value)
110
+ end
111
+
38
112
  # Append `appium:` prefix for Appium following W3C spec
39
113
  # https://www.w3.org/TR/webdriver/#dfn-validate-capabilities
40
114
  #
@@ -49,7 +123,7 @@ module Appium
49
123
  next if value.is_a?(String) && value.empty?
50
124
 
51
125
  capability_name = name.to_s
52
- w3c_name = appium_prefix?(capability_name, w3c_capabilities) ? name : "appium:#{capability_name}"
126
+ w3c_name = appium_prefix?(capability_name, w3c_capabilities) ? name : "#{APPIUM_PREFIX}#{capability_name}"
53
127
 
54
128
  w3c_capabilities[w3c_name] = value
55
129
  end
@@ -59,7 +133,6 @@ module Appium
59
133
 
60
134
  private
61
135
 
62
- APPIUM_PREFIX = 'appium:'.freeze
63
136
  def appium_prefix?(capability_name, w3c_capabilities)
64
137
  snake_cased_capability_names = ::Selenium::WebDriver::Remote::W3C::Capabilities::KNOWN.map(&:to_s)
65
138
  camel_cased_capability_names = snake_cased_capability_names.map(&w3c_capabilities.method(:camel_case))
@@ -69,18 +142,53 @@ module Appium
69
142
  capability_name.start_with?(APPIUM_PREFIX)
70
143
  end
71
144
 
72
- # Use capabilities directory because Appium's capability is based on W3C one.
73
- # Called in bridge.create_session(desired_capabilities) from Parent class
145
+ def json_create(oss_status, value)
146
+ if oss_status
147
+ ::Selenium::WebDriver.logger.info 'Detected OSS dialect.'
148
+ @dialect = :oss
149
+ ::Selenium::WebDriver::Remote::Capabilities.json_create(value)
150
+ else
151
+ ::Selenium::WebDriver.logger.info 'Detected W3C dialect.'
152
+ @dialect = :w3c
153
+ ::Selenium::WebDriver::Remote::W3C::Capabilities.json_create(value)
154
+ end
155
+ end
156
+
157
+ def delete_force_mjsonwp(capabilities)
158
+ w3c_capabilities = ::Selenium::WebDriver::Remote::W3C::Capabilities.new
159
+
160
+ capabilities = capabilities.__send__(:capabilities) unless capabilities.is_a?(Hash)
161
+ capabilities.each do |name, value|
162
+ next if value.nil?
163
+ next if value.is_a?(String) && value.empty?
164
+ next if name == :forceMjsonwp
165
+
166
+ w3c_capabilities[name] = value
167
+ end
168
+
169
+ w3c_capabilities
170
+ end
171
+
74
172
  def merged_capabilities(desired_capabilities)
75
- new_caps = add_appium_prefix(desired_capabilities)
76
- w3c_capabilities = ::Selenium::WebDriver::Remote::W3C::Capabilities.from_oss(new_caps)
173
+ force_mjsonwp = desired_capabilities[:forceMjsonwp]
174
+ desired_capabilities = delete_force_mjsonwp(desired_capabilities) unless force_mjsonwp.nil?
77
175
 
78
- {
79
- desiredCapabilities: desired_capabilities,
80
- capabilities: {
81
- firstMatch: [w3c_capabilities]
176
+ if force_mjsonwp
177
+ {
178
+ desiredCapabilities: desired_capabilities
82
179
  }
83
- }
180
+ else
181
+ new_caps = add_appium_prefix(desired_capabilities)
182
+ w3c_capabilities = ::Selenium::WebDriver::Remote::W3C::Capabilities.from_oss(new_caps)
183
+
184
+ {
185
+ desiredCapabilities: desired_capabilities,
186
+ capabilities: {
187
+ alwaysMatch: w3c_capabilities,
188
+ firstMatch: [{}]
189
+ }
190
+ }
191
+ end
84
192
  end
85
193
  end # class Bridge
86
194
  end # class Base
@@ -0,0 +1,13 @@
1
+ module Appium
2
+ module Core
3
+ class Base
4
+ class Bridge
5
+ class MJSONWP < ::Selenium::WebDriver::Remote::OSS::Bridge
6
+ def commands(command)
7
+ ::Appium::Core::Commands::COMMANDS_EXTEND_MJSONWP[command]
8
+ end
9
+ end # class MJSONWP
10
+ end # class Bridge
11
+ end # class Base
12
+ end # module Core
13
+ end # module Appium
@@ -0,0 +1,160 @@
1
+ module Appium
2
+ module Core
3
+ class Base
4
+ class Bridge
5
+ class W3C < ::Selenium::WebDriver::Remote::W3C::Bridge
6
+ # Used for default duration of each touch actions
7
+ # Override from 250 milliseconds to 50 milliseconds
8
+ ::Selenium::WebDriver::PointerActions::DEFAULT_MOVE_DURATION = 0.05
9
+
10
+ def commands(command)
11
+ ::Appium::Core::Commands::COMMANDS_EXTEND_W3C[command]
12
+ end
13
+
14
+ # Perform touch actions for W3C module.
15
+ # Generate `touch` pointer action here and users can use this via `driver.action`
16
+ # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
17
+ # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/PointerActions.html
18
+ # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/KeyActions.html
19
+ #
20
+ # @private
21
+ # For Appium
22
+ # override
23
+ #
24
+ # @example
25
+ #
26
+ # element = @driver.find_element(:id, "some id")
27
+ # @driver.action.click(element).perform # The `click` is a part of `PointerActions`
28
+ #
29
+ def action(async = false)
30
+ ::Selenium::WebDriver::W3CActionBuilder.new self,
31
+ ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'touch'),
32
+ ::Selenium::WebDriver::Interactions.key('keyboard'),
33
+ async
34
+ end
35
+ alias actions action
36
+
37
+ # For Appium
38
+ # override
39
+ def page_source
40
+ # For W3C
41
+ # execute_script('var source = document.documentElement.outerHTML;' \
42
+ # 'if (!source) { source = new XMLSerializer().serializeToString(document); }' \
43
+ # 'return source;')
44
+ execute :get_page_source
45
+ end
46
+
47
+ # For Appium
48
+ # override
49
+ def element_attribute(element, name)
50
+ # For W3C
51
+ # execute_atom :getAttribute, element, name
52
+ execute :get_element_attribute, id: element.ref, name: name
53
+ end
54
+
55
+ # For Appium
56
+ # override
57
+ def find_element_by(how, what, parent = nil)
58
+ how, what = convert_locators(how, what)
59
+
60
+ id = if parent
61
+ execute :find_child_element, { id: parent }, { using: how, value: what }
62
+ else
63
+ execute :find_element, {}, { using: how, value: what }
64
+ end
65
+ ::Selenium::WebDriver::Element.new self, element_id_from(id)
66
+ end
67
+
68
+ # For Appium
69
+ # override
70
+ def find_elements_by(how, what, parent = nil)
71
+ how, what = convert_locators(how, what)
72
+
73
+ ids = if parent
74
+ execute :find_child_elements, { id: parent }, { using: how, value: what }
75
+ else
76
+ execute :find_elements, {}, { using: how, value: what }
77
+ end
78
+
79
+ ids.map { |id| ::Selenium::WebDriver::Element.new self, element_id_from(id) }
80
+ end
81
+
82
+ # For Appium
83
+ # override
84
+ # called in `extend DriverExtensions::HasNetworkConnection`
85
+ def network_connection
86
+ execute :get_network_connection
87
+ end
88
+
89
+ # For Appium
90
+ # override
91
+ # called in `extend DriverExtensions::HasNetworkConnection`
92
+ def network_connection=(type)
93
+ execute :set_network_connection, {}, { parameters: { type: type } }
94
+ end
95
+
96
+ # For Appium
97
+ # No implementation for W3C webdriver module
98
+ # called in `extend DriverExtensions::HasLocation`
99
+ def location
100
+ obj = execute(:get_location) || {}
101
+ ::Selenium::WebDriver::Location.new obj['latitude'], obj['longitude'], obj['altitude']
102
+ end
103
+
104
+ # For Appium
105
+ # No implementation for W3C webdriver module
106
+ # called in `extend DriverExtensions::HasLocation`
107
+ def set_location(lat, lon, alt)
108
+ loc = { latitude: lat, longitude: lon, altitude: alt }
109
+ execute :set_location, {}, { location: loc }
110
+ end
111
+
112
+ #
113
+ # logs
114
+ #
115
+ # For Appium
116
+ # No implementation for W3C webdriver module
117
+ def available_log_types
118
+ types = execute :get_available_log_types
119
+ Array(types).map(&:to_sym)
120
+ end
121
+
122
+ # For Appium
123
+ # No implementation for W3C webdriver module
124
+ def log(type)
125
+ data = execute :get_log, {}, { type: type.to_s }
126
+
127
+ Array(data).map do |l|
128
+ begin
129
+ ::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
130
+ rescue KeyError
131
+ next
132
+ end
133
+ end
134
+ end
135
+
136
+ private
137
+
138
+ # Don't convert locators for Appium Client
139
+ # TODO: Only for Appium. Ideally, we'd like to keep the selenium-webdriver
140
+ def convert_locators(how, what)
141
+ # case how
142
+ # when 'class name'
143
+ # how = 'css selector'
144
+ # what = ".#{escape_css(what)}"
145
+ # when 'id'
146
+ # how = 'css selector'
147
+ # what = "##{escape_css(what)}"
148
+ # when 'name'
149
+ # how = 'css selector'
150
+ # what = "*[name='#{escape_css(what)}']"
151
+ # when 'tag name'
152
+ # how = 'css selector'
153
+ # end
154
+ [how, what]
155
+ end
156
+ end # class W3C
157
+ end # class Bridge
158
+ end # class Base
159
+ end # module Core
160
+ end # module Appium
@@ -56,6 +56,18 @@ module Appium
56
56
  def back
57
57
  navigate.back
58
58
  end
59
+
60
+ # Get the device window's logs.
61
+ # @return [String]
62
+ #
63
+ # @example
64
+ #
65
+ # @driver.logs.available_types # [:syslog, :crashlog, :performance]
66
+ # @driver.logs.get :syslog # []
67
+ #
68
+ def logs
69
+ @logs ||= Logs.new(@bridge)
70
+ end
59
71
  end # class Driver
60
72
  end # class Base
61
73
  end # module Core
@@ -23,7 +23,7 @@ module Appium
23
23
  get_system_bars: [:get, 'session/:session_id/appium/device/system_bars'.freeze],
24
24
  get_display_density: [:get, 'session/:session_id/appium/device/display_density'.freeze],
25
25
  is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'.freeze],
26
- get_network_connection: [:get, 'session/:session_id/network_connection'.freeze],
26
+ get_network_connection: [:get, 'session/:session_id/network_connection'.freeze], # defined also in OSS
27
27
  get_performance_data_types: [:post, 'session/:session_id/appium/performanceData/types'.freeze],
28
28
  stop_recording_screen: [:post, 'session/:session_id/appium/stop_recording_screen'.freeze]
29
29
  # iOS
@@ -59,7 +59,7 @@ module Appium
59
59
  COMMAND_ANDROID = {
60
60
  start_activity: [:post, 'session/:session_id/appium/device/start_activity'.freeze],
61
61
  end_coverage: [:post, 'session/:session_id/appium/app/end_test_coverage'.freeze],
62
- set_network_connection: [:post, 'session/:session_id/network_connection'.freeze],
62
+ set_network_connection: [:post, 'session/:session_id/network_connection'.freeze], # defined also in OSS
63
63
  get_performance_data: [:post, 'session/:session_id/appium/getPerformanceData'.freeze],
64
64
  start_recording_screen: [:post, 'session/:session_id/appium/start_recording_screen'.freeze]
65
65
  }.freeze
@@ -89,23 +89,24 @@ module Appium
89
89
  # The fix will be included in selenium-3.8.2
90
90
  get_page_source: [:get, 'session/:session_id/source'.freeze],
91
91
 
92
- ## Add to W3C commands
93
- # rotatable
92
+ ## Add OSS commands to W3C commands
93
+ ### rotatable
94
94
  get_screen_orientation: [:get, 'session/:session_id/orientation'.freeze],
95
95
  set_screen_orientation: [:post, 'session/:session_id/orientation'.freeze],
96
96
 
97
97
  get_location: [:get, 'session/:session_id/location'.freeze],
98
98
  set_location: [:post, 'session/:session_id/location'.freeze],
99
99
 
100
- get_network_connection: [:get, 'session/:session_id/network_connection'.freeze],
101
- set_network_connection: [:post, 'session/:session_id/network_connection'.freeze],
102
-
103
- # For IME
100
+ ### For IME
104
101
  ime_get_available_engines: [:get, 'session/:session_id/ime/available_engines'.freeze],
105
102
  ime_get_active_engine: [:get, 'session/:session_id/ime/active_engine'.freeze],
106
103
  ime_is_activated: [:get, 'session/:session_id/ime/activated'.freeze],
107
104
  ime_deactivate: [:post, 'session/:session_id/ime/deactivate'.freeze],
108
- ime_activate_engine: [:post, 'session/:session_id/ime/activate'.freeze]
105
+ ime_activate_engine: [:post, 'session/:session_id/ime/activate'.freeze],
106
+
107
+ ### Logs
108
+ get_available_log_types: [:get, 'session/:session_id/log/types'.freeze],
109
+ get_log: [:post, 'session/:session_id/log'.freeze]
109
110
  }
110
111
  ).freeze
111
112
  end
@@ -112,6 +112,12 @@ module Appium
112
112
  # @!method get_network_connection
113
113
  # Get the device network connection current status
114
114
  # See set_network_connection method for return value
115
+ #
116
+ # @example
117
+ #
118
+ # @driver.network_connection_type #=> 6
119
+ # @driver.get_network_connection #=> 6
120
+ #
115
121
 
116
122
  # @!method open_notifications
117
123
  # Open Android notifications
@@ -561,10 +567,10 @@ module Appium
561
567
 
562
568
  # @private
563
569
  def create_bridge_command(method)
564
- ::Appium::Core::Base::CoreBridgeMJSONWP.class_eval do
570
+ ::Appium::Core::Base::Bridge::MJSONWP.class_eval do
565
571
  block_given? ? class_eval(&Proc.new) : define_method(method) { execute method }
566
572
  end
567
- ::Appium::Core::Base::CoreBridgeW3C.class_eval do
573
+ ::Appium::Core::Base::Bridge::W3C.class_eval do
568
574
  block_given? ? class_eval(&Proc.new) : define_method(method) { execute method }
569
575
  end
570
576
  end
@@ -9,21 +9,23 @@ module Appium
9
9
  # @return [[Selenium::WebDriver::LogEntry]] A list of logs data.
10
10
  #
11
11
  # @example
12
- # Appium::Core::Logs.new(driver).get("syslog") #=> [[Selenium::WebDriver::LogEntry]]
13
- # Appium::Core::Logs.new(driver).get(:syslog) #=> [[Selenium::WebDriver::LogEntry]]
12
+ #
13
+ # @driver.logs.get "syslog" # []
14
+ # @driver.logs.get :syslog # []
14
15
  #
15
16
  def get(type)
16
- @bridge.get type
17
+ @bridge.log type
17
18
  end
18
19
 
19
20
  # Get a list of available log types
20
21
  #
21
22
  # @return [[Hash]] A list of available log types.
22
23
  # @example
23
- # Appium::Core::Logs.new(driver).available_types #=> [:syslog, :crashlog, :performance]
24
+ #
25
+ # @driver.logs.available_types # [:syslog, :crashlog, :performance]
24
26
  #
25
27
  def available_types
26
- @bridge.available_types
28
+ @bridge.available_log_types
27
29
  end
28
30
  end
29
31
  end # module Core
@@ -1,6 +1,6 @@
1
1
  module Appium
2
2
  module Core
3
- VERSION = '1.2.3'.freeze unless defined? ::Appium::Core::VERSION
4
- DATE = '2017-12-27'.freeze unless defined? ::Appium::Core::DATE
3
+ VERSION = '1.2.4'.freeze unless defined? ::Appium::Core::VERSION
4
+ DATE = '2018-01-03'.freeze unless defined? ::Appium::Core::DATE
5
5
  end
6
6
  end
data/release_notes.md CHANGED
@@ -1,3 +1,13 @@
1
+ #### v1.2.4 2018-01-03
2
+
3
+ - [7032bc0](https://github.com/appium/ruby_lib_core/commit/7032bc02acc44640542eb545067a4125a7f1811f) Release 1.2.4
4
+ - [2396b08](https://github.com/appium/ruby_lib_core/commit/2396b08f99a9630827f6805dde2716b0bd0b14f7) Add some missing commands for w3c (#42)
5
+ - [db6aa69](https://github.com/appium/ruby_lib_core/commit/db6aa6954566f601bb038aa7a7aa6884612e19fe) Switchable w3c format caps from capabilities (#41)
6
+ - [dac4ff1](https://github.com/appium/ruby_lib_core/commit/dac4ff16271361ceaecf1f613f85cff0bb6c4be2) Add capability for create session following w3c (#40)
7
+ - [f2c25ce](https://github.com/appium/ruby_lib_core/commit/f2c25ce9e551790beb4cf6abb170a02a70955eb4) update travis (#39)
8
+ - [2ea7908](https://github.com/appium/ruby_lib_core/commit/2ea7908a5e77f4f7275a3e51c1abae7966cf2d94) remove bug fixes part in unreleased
9
+
10
+
1
11
  #### v1.2.3 2017-12-27
2
12
 
3
13
  - [26b8392](https://github.com/appium/ruby_lib_core/commit/26b83923a50257922030c7ccb83e110aff55eee5) Release 1.2.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-27 00:00:00.000000000 Z
11
+ date: 2018-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '12.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '12.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -204,13 +204,13 @@ files:
204
204
  - lib/appium_lib_core/common.rb
205
205
  - lib/appium_lib_core/common/base.rb
206
206
  - lib/appium_lib_core/common/base/bridge.rb
207
+ - lib/appium_lib_core/common/base/bridge/msjsonwp.rb
208
+ - lib/appium_lib_core/common/base/bridge/w3c.rb
207
209
  - lib/appium_lib_core/common/base/capabilities.rb
208
210
  - lib/appium_lib_core/common/base/command.rb
209
211
  - lib/appium_lib_core/common/base/driver.rb
210
212
  - lib/appium_lib_core/common/base/http_default.rb
211
- - lib/appium_lib_core/common/base/msjsonwp_bridge.rb
212
213
  - lib/appium_lib_core/common/base/search_context.rb
213
- - lib/appium_lib_core/common/base/w3c_bridge.rb
214
214
  - lib/appium_lib_core/common/base/wait.rb
215
215
  - lib/appium_lib_core/common/command.rb
216
216
  - lib/appium_lib_core/common/device.rb
@@ -1,11 +0,0 @@
1
- module Appium
2
- module Core
3
- class Base
4
- class CoreBridgeMJSONWP < ::Selenium::WebDriver::Remote::OSS::Bridge
5
- def commands(command)
6
- ::Appium::Core::Commands::COMMANDS_EXTEND_MJSONWP[command]
7
- end
8
- end # class CoreBridgeMJSONWP
9
- end # class Base
10
- end # module Core
11
- end # module Appium
@@ -1,129 +0,0 @@
1
- module Appium
2
- module Core
3
- class Base
4
- class CoreBridgeW3C < ::Selenium::WebDriver::Remote::W3C::Bridge
5
- # Used for default duration of each touch actions
6
- # Override from 250 milliseconds to 50 milliseconds
7
- ::Selenium::WebDriver::PointerActions::DEFAULT_MOVE_DURATION = 0.05
8
-
9
- def commands(command)
10
- ::Appium::Core::Commands::COMMANDS_EXTEND_W3C[command]
11
- end
12
-
13
- # Perform touch actions for W3C module. Generate `touch` pointer action here and users can use this via `driver.action`
14
- # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/W3CActionBuilder.html
15
- # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/PointerActions.html
16
- # - https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/KeyActions.html
17
- #
18
- # @private
19
- # For Appium
20
- # override
21
- #
22
- # @example
23
- #
24
- # element = @driver.find_element(:id, "some id")
25
- # @driver.action.click(element).perform # The `click` is a part of `PointerActions`
26
- #
27
- def action(async = false)
28
- ::Selenium::WebDriver::W3CActionBuilder.new self,
29
- ::Selenium::WebDriver::Interactions.pointer(:touch, name: 'touch'),
30
- ::Selenium::WebDriver::Interactions.key('keyboard'),
31
- async
32
- end
33
- alias actions action
34
-
35
- # For Appium
36
- # override
37
- def page_source
38
- # For W3C
39
- # execute_script('var source = document.documentElement.outerHTML;' \
40
- # 'if (!source) { source = new XMLSerializer().serializeToString(document); }' \
41
- # 'return source;')
42
- execute :get_page_source
43
- end
44
-
45
- # For Appium
46
- # override
47
- def element_attribute(element, name)
48
- # For W3C
49
- # execute_atom :getAttribute, element, name
50
- execute :get_element_attribute, id: element.ref, name: name
51
- end
52
-
53
- # For Appium
54
- # override
55
- def find_element_by(how, what, parent = nil)
56
- how, what = convert_locators(how, what)
57
-
58
- id = if parent
59
- execute :find_child_element, { id: parent }, { using: how, value: what }
60
- else
61
- execute :find_element, {}, { using: how, value: what }
62
- end
63
- ::Selenium::WebDriver::Element.new self, element_id_from(id)
64
- end
65
-
66
- # For Appium
67
- # override
68
- def find_elements_by(how, what, parent = nil)
69
- how, what = convert_locators(how, what)
70
-
71
- ids = if parent
72
- execute :find_child_elements, { id: parent }, { using: how, value: what }
73
- else
74
- execute :find_elements, {}, { using: how, value: what }
75
- end
76
-
77
- ids.map { |id| ::Selenium::WebDriver::Element.new self, element_id_from(id) }
78
- end
79
-
80
- # For Appium
81
- # override
82
- def location
83
- obj = execute(:get_location) || {}
84
- Location.new obj['latitude'], obj['longitude'], obj['altitude']
85
- end
86
-
87
- # For Appium
88
- # override
89
- def set_location(lat, lon, alt)
90
- loc = { latitude: lat, longitude: lon, altitude: alt }
91
- execute :set_location, {}, { location: loc }
92
- end
93
-
94
- # For Appium
95
- # override
96
- def network_connection
97
- execute :get_network_connection
98
- end
99
-
100
- # For Appium
101
- # override
102
- def network_connection=(type)
103
- execute :set_network_connection, {}, { parameters: { type: type } }
104
- end
105
-
106
- private
107
-
108
- # Don't convert locators for Appium Client
109
- # TODO: Only for Appium. Ideally, we'd like to keep the selenium-webdriver
110
- def convert_locators(how, what)
111
- # case how
112
- # when 'class name'
113
- # how = 'css selector'
114
- # what = ".#{escape_css(what)}"
115
- # when 'id'
116
- # how = 'css selector'
117
- # what = "##{escape_css(what)}"
118
- # when 'name'
119
- # how = 'css selector'
120
- # what = "*[name='#{escape_css(what)}']"
121
- # when 'tag name'
122
- # how = 'css selector'
123
- # end
124
- [how, what]
125
- end
126
- end # class CoreBridgeW3C
127
- end # class Base
128
- end # module Core
129
- end # module Appium