appium_lib 9.3.4 → 9.3.5

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.
@@ -53,6 +53,13 @@ textfield(value) # Return a XCUIElementTypeSecureTextField or XCUIElementTypeTex
53
53
  finds_exact(value) # Return any elements include `value` as its name attributes.
54
54
  ```
55
55
 
56
+ ### with Class Chain
57
+ - require Appium 1.6.4+
58
+ - https://github.com/appium/appium-xcuitest-driver/pull/391
59
+ - https://github.com/appium/java-client/pull/599/files
60
+ - WebDriverAgent
61
+ - https://github.com/facebook/WebDriverAgent/wiki/Queries
62
+
56
63
  ### with XPath
57
64
  - It is better to avoid XPath strategy.
58
65
  - https://github.com/appium/appium/blob/v1.6.2/docs/en/advanced-concepts/migrating-to-xcuitest.md#xpath-locator-strategy
@@ -54,7 +54,10 @@ describe 'device/device' do
54
54
 
55
55
  t 'background_app homescreen' do
56
56
  background_app(-1) # background_app(nil) should work as same.
57
- screen.must_raise ::Selenium::WebDriver::Error::NoSuchElementError
57
+
58
+ screen.must_equal 'UICatalog'
59
+ # TODO: Should update this assert.
60
+ # screen.must_raise ::Selenium::WebDriver::Error::NoSuchElementError
58
61
  end
59
62
 
60
63
  t 'reset' do
@@ -80,13 +83,30 @@ describe 'device/device' do
80
83
  end
81
84
 
82
85
  t 'action_chain' do
83
- Appium::TouchAction.new.press(element: id('ButtonsExplain')).perform
86
+ Appium::TouchAction.new.press(element: text(app_strings['ButtonsExplain'])).perform
84
87
  wait { id 'ArrowButton' } # successfully transitioned to buttons page
85
88
  go_back
86
89
  end
87
90
 
88
91
  t 'swipe' do
89
- swipe start_x: 75, start_y: 500, offset_x: 75, offset_y: 0, duration: 800
92
+ touch_action = swipe(start_x: 75, start_y: 500, offset_x: 75, offset_y: 20, duration: 500)
93
+ touch_action.actions.must_equal []
94
+
95
+ touch_action = Appium::TouchAction.new.swipe(start_x: 75, start_y: 500, offset_x: 75, offset_y: 20, duration: 500)
96
+
97
+ touch_action.actions[0][:action].must_equal :press
98
+ touch_action.actions[0][:options].must_equal(x: 75, y: 500)
99
+
100
+ touch_action.actions[1][:action].must_equal :wait,
101
+ touch_action.actions[1][:options].must_equal(ms: 500)
102
+
103
+ touch_action.actions[2][:action].must_equal :moveTo
104
+ touch_action.actions[2][:options].must_equal(x: 75, y: 20)
105
+
106
+ touch_action.actions[3][:action].must_equal :release
107
+
108
+ touch_action.perform
109
+ touch_action.actions.must_equal []
90
110
  end
91
111
 
92
112
  t 'pull_file' do
@@ -0,0 +1,20 @@
1
+ # rake ios[ios/mobile_methods]
2
+ describe 'ios/mobile_methods' do
3
+ def before_first
4
+ screen.must_equal catalog
5
+ end
6
+
7
+ t 'an element with class chain' do
8
+ element = find_element :class_chain, 'XCUIElementTypeWindow/*/*/XCUIElementTypeStaticText'
9
+
10
+ element.name.must_equal catalog
11
+ end
12
+
13
+ t 'elements with class chain' do
14
+ elements = find_elements :class_chain, 'XCUIElementTypeWindow/*/*'
15
+
16
+ elements.size.must_equal 2
17
+ elements[0].name.must_equal catalog
18
+ elements[1].name.must_be_nil
19
+ end
20
+ end
@@ -29,30 +29,34 @@ module Appium
29
29
  end
30
30
 
31
31
  # @private
32
- def scroll_uiselector(content)
33
- "new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(#{content}.instance(0));"
32
+ def scroll_uiselector(content, index = 0)
33
+ "new UiScrollable(new UiSelector().scrollable(true).instance(#{index})).scrollIntoView(#{content}.instance(0));"
34
34
  end
35
35
 
36
36
  # Scroll to the first element containing target text or description.
37
- # @param text [String] the text to search for in the text value and content description
37
+ # @param text [String] the text or resourceId to search for in the text value and content description
38
+ # @param scrollable_index [Integer] the index for scrollable views.
38
39
  # @return [Element] the element scrolled to
39
- def scroll_to(text)
40
+ def scroll_to(text, scrollable_index = 0)
40
41
  text = %("#{text}")
41
42
 
42
- args = scroll_uiselector("new UiSelector().textContains(#{text})") +
43
- scroll_uiselector("new UiSelector().descriptionContains(#{text})")
43
+ args = scroll_uiselector("new UiSelector().textContains(#{text})", scrollable_index) +
44
+ scroll_uiselector("new UiSelector().descriptionContains(#{text})", scrollable_index) +
45
+ scroll_uiselector(resource_id(text, "new UiSelector().resourceId(#{text});"), scrollable_index)
44
46
 
45
47
  find_element :uiautomator, args
46
48
  end
47
49
 
48
50
  # Scroll to the first element with the exact target text or description.
49
- # @param text [String] the text to search for in the text value and content description
51
+ # @param text [String] the text or resourceId to search for in the text value and content description
52
+ # @param scrollable_index [Integer] the index for scrollable views.
50
53
  # @return [Element] the element scrolled to
51
- def scroll_to_exact(text)
54
+ def scroll_to_exact(text, scrollable_index = 0)
52
55
  text = %("#{text}")
53
56
 
54
- args = scroll_uiselector("new UiSelector().text(#{text})") +
55
- scroll_uiselector("new UiSelector().description(#{text})")
57
+ args = scroll_uiselector("new UiSelector().text(#{text})", scrollable_index) +
58
+ scroll_uiselector("new UiSelector().description(#{text})", scrollable_index) +
59
+ scroll_uiselector(resource_id(text, "new UiSelector().resourceId(#{text});"), scrollable_index)
56
60
 
57
61
  find_element :uiautomator, args
58
62
  end
@@ -256,7 +256,7 @@ module Appium
256
256
  # @param on_match [String] the string to return on resourceId match
257
257
  #
258
258
  # @return [String] empty string on failure, on_match on successful match
259
- def _resource_id(string, on_match)
259
+ def resource_id(string, on_match)
260
260
  return '' unless string
261
261
 
262
262
  # unquote the string
@@ -289,14 +289,14 @@ module Appium
289
289
  value = %("#{value}")
290
290
 
291
291
  if class_name == '*'
292
- return (_resource_id(value, "new UiSelector().resourceId(#{value});") +
292
+ return (resource_id(value, "new UiSelector().resourceId(#{value});") +
293
293
  "new UiSelector().descriptionContains(#{value});" \
294
294
  "new UiSelector().textContains(#{value});")
295
295
  end
296
296
 
297
297
  class_name = %("#{class_name}")
298
298
 
299
- _resource_id(value, "new UiSelector().className(#{class_name}).resourceId(#{value});") +
299
+ resource_id(value, "new UiSelector().className(#{class_name}).resourceId(#{value});") +
300
300
  "new UiSelector().className(#{class_name}).descriptionContains(#{value});" \
301
301
  "new UiSelector().className(#{class_name}).textContains(#{value});"
302
302
  end
@@ -326,14 +326,14 @@ module Appium
326
326
  value = %("#{value}")
327
327
 
328
328
  if class_name == '*'
329
- return (_resource_id(value, "new UiSelector().resourceId(#{value});") +
329
+ return (resource_id(value, "new UiSelector().resourceId(#{value});") +
330
330
  "new UiSelector().description(#{value});" \
331
331
  "new UiSelector().text(#{value});")
332
332
  end
333
333
 
334
334
  class_name = %("#{class_name}")
335
335
 
336
- _resource_id(value, "new UiSelector().className(#{class_name}).resourceId(#{value});") +
336
+ resource_id(value, "new UiSelector().className(#{class_name}).resourceId(#{value});") +
337
337
  "new UiSelector().className(#{class_name}).description(#{value});" \
338
338
  "new UiSelector().className(#{class_name}).text(#{value});"
339
339
  end
@@ -13,6 +13,9 @@ module Appium
13
13
  open_notifications: [:post, 'session/:session_id/appium/device/open_notifications'.freeze],
14
14
  toggle_airplane_mode: [:post, 'session/:session_id/appium/device/toggle_airplane_mode'.freeze],
15
15
  current_activity: [:get, 'session/:session_id/appium/device/current_activity'.freeze],
16
+ get_system_bars: [:get, 'session/:session_id/appium/device/system_bars'.freeze],
17
+ get_display_density: [:get, 'session/:session_id/appium/device/display_density'.freeze],
18
+ is_keyboard_shown: [:get, 'session/:session_id/appium/device/is_keyboard_shown'.freeze],
16
19
  get_network_connection: [:get, 'session/:session_id/network_connection'.freeze],
17
20
  get_performance_data_types: [:post, 'session/:session_id/appium/performanceData/types'.freeze],
18
21
 
@@ -1,5 +1,5 @@
1
1
  module Appium
2
2
  # Version and Date are defined on the 'Appium' module, not 'Appium::Common'
3
- VERSION = '9.3.4'.freeze unless defined? ::Appium::VERSION
4
- DATE = '2017-03-16'.freeze unless defined? ::Appium::DATE
3
+ VERSION = '9.3.5'.freeze unless defined? ::Appium::VERSION
4
+ DATE = '2017-03-26'.freeze unless defined? ::Appium::DATE
5
5
  end
@@ -23,6 +23,30 @@ module Appium
23
23
 
24
24
  # @!method current_activity
25
25
 
26
+ # @!method get_system_bars
27
+ # Get system bar's information
28
+ # @return [String] System bar
29
+ #
30
+ # ```ruby
31
+ # get_system_bars
32
+ # ```
33
+
34
+ # @!method get_display_density
35
+ # Get connected device's density.
36
+ # @return [Integer] The size of density
37
+ #
38
+ # ```ruby
39
+ # get_display_density # 320
40
+ # ```
41
+
42
+ # @!method is_keyboard_shown
43
+ # Get whether keyboard is displayed or not.
44
+ # @return [Bool] Return true if keyboard is shown. Return false if keyboard is hidden.
45
+ #
46
+ # ```ruby
47
+ # is_keyboard_shown # false
48
+ # ```
49
+
26
50
  # @!method launch_app
27
51
  # Start the simulator and application configured with desired capabilities
28
52
 
@@ -538,7 +562,7 @@ module Appium
538
562
  # @return [String] The context currently being used.
539
563
 
540
564
  # @!method available_contexts
541
- # @return [Array<String>] All usable contexts, as an array of strings.
565
+ # @return [Array<String>] All usable contexts, as an array of strings.
542
566
 
543
567
  # Perform a block within the given context, then switch back to the starting context.
544
568
  # @param context (String) The context to switch to for the duration of the block.
@@ -163,6 +163,8 @@ module Appium
163
163
  end
164
164
  end # self
165
165
 
166
+ attr_reader :actions
167
+
166
168
  # Create a new multi-action
167
169
  def initialize
168
170
  @actions = []
@@ -177,6 +179,7 @@ module Appium
177
179
  # Ask Appium to perform the actions
178
180
  def perform
179
181
  $driver.multi_touch @actions
182
+ @actions.clear
180
183
  end
181
184
  end # class MultiTouch
182
185
  end # module Appium
@@ -7,6 +7,15 @@ module Appium
7
7
  # ```ruby
8
8
  # action = TouchAction.new.press(x: 45, y: 100).wait(5).release
9
9
  # action.perform
10
+ # ```
11
+ #
12
+ # Or each methods can call without `TouchAction.new` as the following.
13
+ # In this case, `perform` is called automatically.
14
+ # ```ruby
15
+ # # called `swipe(...).perform` in this method.
16
+ # swipe(start_x: 75, start_y: 500, offset_x: 75, offset_y: 20, duration: 500)
17
+ # ```
18
+
10
19
  class TouchAction
11
20
  ACTIONS = [:move_to, :long_press, :double_tap, :two_finger_tap, :press, :release, :tap, :wait, :perform].freeze
12
21
  COMPLEX_ACTIONS = [:swipe].freeze
@@ -167,6 +176,7 @@ module Appium
167
176
  # Ask the driver to perform all actions in this action chain.
168
177
  def perform
169
178
  $driver.touch_actions @actions
179
+ @actions.clear
170
180
  self
171
181
  end
172
182
 
@@ -16,9 +16,23 @@ module Appium
16
16
  # find_elements :predicate, 'wdName == "Buttons"'
17
17
  # find_elements :predicate, 'wdValue == "SearchBar" AND isWDDivisible == 1'
18
18
  # ```
19
+ #
20
+ # @!method ios_class_chain_find
21
+ # Only for XCUITest(WebDriverAgent)
22
+ # find_element/s can be used with a [class chain]( https://github.com/facebook/WebDriverAgent/wiki/Queries)
23
+ #
24
+ # ```ruby
25
+ # # select the third child button of the first child window element
26
+ # find_elements :class_chain, 'XCUIElementTypeWindow/XCUIElementTypeButton[3]'
27
+ # # select all the children windows
28
+ # find_elements :class_chain, 'XCUIElementTypeWindow'
29
+ # # select the second last child of the second child window
30
+ # find_elements :class_chain, 'XCUIElementTypeWindow[2]/XCUIElementTypeAny[-2]'
31
+ # ```
19
32
  def extended(_mod)
20
33
  ::Appium::Driver::SearchContext::FINDERS[:uiautomation] = '-ios uiautomation'
21
34
  ::Appium::Driver::SearchContext::FINDERS[:predicate] = '-ios predicate string'
35
+ ::Appium::Driver::SearchContext::FINDERS[:class_chain] = '-ios class chain'
22
36
  end
23
37
  end # class << self
24
38
  end # module Ios
@@ -1,3 +1,14 @@
1
+ #### v9.3.4 2017-03-16
2
+
3
+ - [2b01065](https://github.com/appium/ruby_lib/commit/2b01065d0b2c2287ed9568cb23de5e459082ef62) Release 9 3 4 (#509)
4
+ - [0abf62f](https://github.com/appium/ruby_lib/commit/0abf62f0fa99d1ce0841a98e86a6ca334a143f0e) add doc for uiautomator (#508)
5
+ - [0199159](https://github.com/appium/ruby_lib/commit/0199159b6f0193884ebcffbfa460b3403859e537) Search with predicate (#504)
6
+ - [dbd8762](https://github.com/appium/ruby_lib/commit/dbd87620b771e7448e9826181b0ae595701ccaa2) Update deactive app for xcuitest (#502)
7
+ - [e06b25e](https://github.com/appium/ruby_lib/commit/e06b25ed1df5ed1a67fcf1a59767cc42ddcdb0d0) add a test for predicate (#499)
8
+ - [447f13c](https://github.com/appium/ruby_lib/commit/447f13cd799652d203bed4fc557b3c251ef2aa2c) Use awesome print 1.7 (#498)
9
+ - [a68cc5f](https://github.com/appium/ruby_lib/commit/a68cc5fc38b64d1d41945024a808df9af90828d7) remove workaround for rainbow (#497)
10
+
11
+
1
12
  #### v9.3.3 2017-02-18
2
13
 
3
14
  - [422a468](https://github.com/appium/ruby_lib/commit/422a4683f10fc99d3731985d532b71e1fe80b4e6) Release 9 3 3 (#494)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.3.4
4
+ version: 9.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - code@bootstraponline.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-16 00:00:00.000000000 Z
11
+ date: 2017-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -331,6 +331,7 @@ files:
331
331
  - ios_tests/lib/ios/specs/ios/element/text.rb
332
332
  - ios_tests/lib/ios/specs/ios/element/textfield.rb
333
333
  - ios_tests/lib/ios/specs/ios/helper.rb
334
+ - ios_tests/lib/ios/specs/ios/mobile_methods.rb
334
335
  - ios_tests/lib/ios/specs/ios/patch.rb
335
336
  - ios_tests/lib/run.rb
336
337
  - ios_tests/readme.md