appium_lib 1.0.0 → 2.0.0

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +48 -14
  3. data/android_tests/Rakefile +5 -2
  4. data/android_tests/api.apk +0 -0
  5. data/android_tests/lib/android/specs/android/element/alert.rb +1 -1
  6. data/android_tests/lib/android/specs/android/element/button.rb +1 -4
  7. data/android_tests/lib/android/specs/android/element/text.rb +15 -18
  8. data/android_tests/lib/android/specs/android/element/textfield.rb +1 -4
  9. data/android_tests/lib/android/specs/android/helper.rb +4 -6
  10. data/android_tests/lib/android/specs/common/device.rb +16 -6
  11. data/android_tests/lib/android/specs/common/helper.rb +6 -6
  12. data/android_tests/lib/android/specs/common/patch.rb +3 -3
  13. data/android_tests/lib/android/specs/driver.rb +1 -1
  14. data/appium_lib.gemspec +11 -11
  15. data/docs/android_docs.md +193 -210
  16. data/docs/ios_docs.md +505 -177
  17. data/docs/migration.md +27 -0
  18. data/docs_gen/make_docs.rb +17 -17
  19. data/ios_tests/Rakefile +6 -3
  20. data/ios_tests/lib/ios/specs/common/helper.rb +1 -1
  21. data/ios_tests/lib/ios/specs/common/patch.rb +2 -2
  22. data/ios_tests/lib/ios/specs/device/device.rb +3 -2
  23. data/ios_tests/lib/ios/specs/device/multi_touch.rb +1 -1
  24. data/ios_tests/lib/ios/specs/device/touch_actions.rb +2 -2
  25. data/ios_tests/lib/ios/specs/driver.rb +5 -5
  26. data/ios_tests/lib/ios/specs/ios/element/alert.rb +5 -5
  27. data/ios_tests/lib/ios/specs/ios/element/button.rb +2 -5
  28. data/ios_tests/lib/ios/specs/ios/element/text.rb +21 -21
  29. data/ios_tests/lib/ios/specs/ios/element/textfield.rb +1 -8
  30. data/ios_tests/lib/ios/specs/ios/helper.rb +2 -2
  31. data/ios_tests/lib/ios/specs/ios/patch.rb +1 -1
  32. data/ios_tests/lib/run.rb +1 -1
  33. data/ios_tests/upload/sauce_storage.rb +13 -12
  34. data/ios_tests/upload/upload.rb +1 -1
  35. data/lib/appium_lib/android/dynamic.rb +31 -30
  36. data/lib/appium_lib/android/element/button.rb +7 -11
  37. data/lib/appium_lib/android/element/generic.rb +5 -5
  38. data/lib/appium_lib/android/element/text.rb +8 -12
  39. data/lib/appium_lib/android/element/textfield.rb +3 -7
  40. data/lib/appium_lib/android/helper.rb +46 -10
  41. data/lib/appium_lib/common/helper.rb +4 -2
  42. data/lib/appium_lib/common/patch.rb +1 -1
  43. data/lib/appium_lib/common/version.rb +2 -2
  44. data/lib/appium_lib/device/device.rb +34 -27
  45. data/lib/appium_lib/device/multi_touch.rb +1 -1
  46. data/lib/appium_lib/device/touch_actions.rb +30 -28
  47. data/lib/appium_lib/driver.rb +3 -3
  48. data/lib/appium_lib/ios/element/button.rb +4 -8
  49. data/lib/appium_lib/ios/element/text.rb +8 -12
  50. data/lib/appium_lib/ios/element/textfield.rb +3 -7
  51. data/lib/appium_lib/ios/helper.rb +70 -40
  52. data/readme.md +6 -70
  53. data/release_notes.md +26 -0
  54. metadata +3 -2
@@ -1,6 +1,6 @@
1
1
  require File.expand_path '../sauce_storage', __FILE__
2
2
 
3
- s = SauceStorage.new debug: true
3
+ s = SauceStorage.new debug: true
4
4
  apk = File.expand_path '../' * 2 + ENV['UPLOAD_FILE'], __FILE__
5
5
 
6
6
  s.upload apk
@@ -1,36 +1,37 @@
1
1
  module Appium
2
2
  class Driver
3
+ # http://developer.android.com/tools/help/uiautomator/UiSelector.html
3
4
  @@map = {
4
- 1 => ['text(String text)', 'SELECTOR_TEXT', 1],
5
- 2 => ['textStartsWith(String text)', 'SELECTOR_START_TEXT', 2],
6
- 3 => ['textContains(String text)', 'SELECTOR_CONTAINS_TEXT', 3],
7
- 4 => ['className(String className)', 'SELECTOR_CLASS', 4],
8
- 5 => ['description(String desc)', 'SELECTOR_DESCRIPTION', 5],
9
- 6 => ['descriptionStartsWith(String desc)', 'SELECTOR_START_DESCRIPTION', 6],
10
- 7 => ['descriptionContains(String desc)', 'SELECTOR_CONTAINS_DESCRIPTION', 7],
11
- 8 => ['index(final int index)', 'SELECTOR_INDEX', 8],
12
- 9 => ['instance(final int instance)', 'SELECTOR_INSTANCE', 9],
13
- 10 => ['enabled(boolean val)', 'SELECTOR_ENABLED', 10],
14
- 11 => ['focused(boolean val)', 'SELECTOR_FOCUSED', 11],
15
- 12 => ['focusable(boolean val)', 'SELECTOR_FOCUSABLE', 12],
16
- 13 => ['scrollable(boolean val)', 'SELECTOR_SCROLLABLE', 13],
17
- 14 => ['clickable(boolean val)', 'SELECTOR_CLICKABLE', 14],
18
- 15 => ['checked(boolean val)', 'SELECTOR_CHECKED', 15],
19
- 16 => ['selected(boolean val)', 'SELECTOR_SELECTED', 16],
20
- # // SELECTOR_ID = 17; // nothing.
21
- 18 => ['packageName(String name)', 'SELECTOR_PACKAGE_NAME', 18],
22
- # // SELECTOR_CHILD = 19; // childSelector(UiSelector selector)
23
- # // SELECTOR_CONTAINER = 20; // containerSelector(UiSelector selector)
24
- # // SELECTOR_PATTERN = 21; // ! private ! patternSelector(UiSelector selector)
25
- # // SELECTOR_PARENT = 22; // fromParent(UiSelector selector)
26
- # // SELECTOR_COUNT = 23; // nothing.
27
- 24 => ['longClickable(boolean val)', 'SELECTOR_LONG_CLICKABLE', 24],
28
- 25 => ['textMatches(String regex)', 'SELECTOR_TEXT_REGEX', 25],
29
- 26 => ['classNameMatches(String regex)', 'SELECTOR_CLASS_REGEX', 26],
30
- 27 => ['descriptionMatches(String regex)', 'SELECTOR_DESCRIPTION_REGEX', 27],
31
- 28 => ['packageNameMatches(String regex)', 'SELECTOR_PACKAGE_NAME_REGEX', 28],
32
- # // start internal methods at 100
33
- 100 => ['getStringAttribute("name")', 'GET_NAME', 100]
5
+ 1 => ['text(String text)', 'SELECTOR_TEXT', 1],
6
+ 2 => ['textStartsWith(String text)', 'SELECTOR_START_TEXT', 2],
7
+ 3 => ['textContains(String text)', 'SELECTOR_CONTAINS_TEXT', 3],
8
+ 4 => ['className(String className)', 'SELECTOR_CLASS', 4],
9
+ 5 => ['description(String desc)', 'SELECTOR_DESCRIPTION', 5],
10
+ 6 => ['descriptionStartsWith(String desc)', 'SELECTOR_START_DESCRIPTION', 6],
11
+ 7 => ['descriptionContains(String desc)', 'SELECTOR_CONTAINS_DESCRIPTION', 7],
12
+ 8 => ['index(final int index)', 'SELECTOR_INDEX', 8],
13
+ 9 => ['instance(final int instance)', 'SELECTOR_INSTANCE', 9],
14
+ 10 => ['enabled(boolean val)', 'SELECTOR_ENABLED', 10],
15
+ 11 => ['focused(boolean val)', 'SELECTOR_FOCUSED', 11],
16
+ 12 => ['focusable(boolean val)', 'SELECTOR_FOCUSABLE', 12],
17
+ 13 => ['scrollable(boolean val)', 'SELECTOR_SCROLLABLE', 13],
18
+ 14 => ['clickable(boolean val)', 'SELECTOR_CLICKABLE', 14],
19
+ 15 => ['checked(boolean val)', 'SELECTOR_CHECKED', 15],
20
+ 16 => ['selected(boolean val)', 'SELECTOR_SELECTED', 16],
21
+ # // SELECTOR_ID = 17; // nothing.
22
+ 18 => ['packageName(String name)', 'SELECTOR_PACKAGE_NAME', 18],
23
+ # // SELECTOR_CHILD = 19; // childSelector(UiSelector selector)
24
+ # // SELECTOR_CONTAINER = 20; // containerSelector(UiSelector selector)
25
+ # // SELECTOR_PATTERN = 21; // ! private ! patternSelector(UiSelector selector)
26
+ # // SELECTOR_PARENT = 22; // fromParent(UiSelector selector)
27
+ # // SELECTOR_COUNT = 23; // nothing.
28
+ 24 => ['longClickable(boolean val)', 'SELECTOR_LONG_CLICKABLE', 24],
29
+ 25 => ['textMatches(String regex)', 'SELECTOR_TEXT_REGEX', 25],
30
+ 26 => ['classNameMatches(String regex)', 'SELECTOR_CLASS_REGEX', 26],
31
+ 27 => ['descriptionMatches(String regex)', 'SELECTOR_DESCRIPTION_REGEX', 27],
32
+ 28 => ['packageNameMatches(String regex)', 'SELECTOR_PACKAGE_NAME_REGEX', 28],
33
+ # // start internal methods at 100
34
+ 100 => ['getStringAttribute("name")', 'GET_NAME', 100]
34
35
  }
35
36
 
36
37
  # @private
@@ -29,7 +29,7 @@ module Appium
29
29
  image_button = string_visible_contains ImageButton, value
30
30
  "#{button} | #{image_button}"
31
31
  end
32
-
32
+
33
33
  public
34
34
 
35
35
  # Find the first button that contains value or by index.
@@ -49,11 +49,13 @@ module Appium
49
49
  xpath _button_contains_string value
50
50
  end
51
51
 
52
- # Find all buttons containing value
52
+ # Find all buttons containing value.
53
+ # If value is omitted, all buttons are returned.
53
54
  # @param value [String] the value to search for
54
55
  # @return [Array<Button>]
55
- def buttons value
56
- xpaths _button_contains_string value
56
+ def buttons value=false
57
+ return xpaths _button_visible_string unless value
58
+ xpaths _button_contains_string value
57
59
  end
58
60
 
59
61
  # Find the first button.
@@ -65,7 +67,7 @@ module Appium
65
67
  # Find the last button.
66
68
  # @return [Button]
67
69
  def last_button
68
- xpath _button_visible_string index: 'last()'
70
+ xpath _button_visible_string index: 'last()'
69
71
  end
70
72
 
71
73
  # Find the first button that exactly matches value.
@@ -81,11 +83,5 @@ module Appium
81
83
  def buttons_exact value
82
84
  xpaths _button_exact_string value
83
85
  end
84
-
85
- # Find all buttons.
86
- # @return [Array<Button>]
87
- def e_buttons
88
- xpaths _button_visible_string
89
- end
90
86
  end # module Android
91
87
  end # module Appium
@@ -34,8 +34,8 @@ module Appium
34
34
  # @return [Element] the element scrolled to
35
35
  def scroll_to text
36
36
  args =
37
- # textContains(text)
38
- [[3, text]],
37
+ # textContains(text)
38
+ [[3, text]],
39
39
  # descriptionContains(text)
40
40
  [[7, text]]
41
41
 
@@ -46,9 +46,9 @@ module Appium
46
46
  # @param text [String] the text to search for in the text value and content description
47
47
  # @return [Element] the element scrolled to
48
48
  def scroll_to_exact text
49
- args =
50
- # text(text)
51
- [[1, text]],
49
+ args =
50
+ # text(text)
51
+ [[1, text]],
52
52
  # description(text)
53
53
  [[5, text]]
54
54
 
@@ -7,48 +7,44 @@ module Appium
7
7
  # @param value [String, Integer] the value to find.
8
8
  # If int then the TextView at that index is returned.
9
9
  # @return [TextView]
10
- def s_text value
10
+ def text value
11
11
  return ele_index TextView, value if value.is_a? Numeric
12
12
  xpath_visible_contains TextView, value
13
13
  end
14
14
 
15
15
  # Find all TextViews containing value.
16
+ # If value is omitted, all texts are returned.
16
17
  # @param value [String] the value to search for
17
18
  # @return [Array<TextView>]
18
- def s_texts value
19
+ def texts value=false
20
+ return tags TextView unless value
19
21
  xpaths_visible_contains TextView, value
20
22
  end
21
23
 
22
24
  # Find the first TextView.
23
25
  # @return [TextView]
24
- def first_s_text
26
+ def first_text
25
27
  first_ele TextView
26
28
  end
27
29
 
28
30
  # Find the last TextView.
29
31
  # @return [TextView]
30
- def last_s_text
32
+ def last_text
31
33
  last_ele TextView
32
34
  end
33
35
 
34
36
  # Find the first TextView that exactly matches value.
35
37
  # @param value [String] the value to match exactly
36
38
  # @return [TextView]
37
- def s_text_exact value
39
+ def text_exact value
38
40
  xpath_visible_exact TextView, value
39
41
  end
40
42
 
41
43
  # Find all TextViews that exactly match value.
42
44
  # @param value [String] the value to match exactly
43
45
  # @return [Array<TextView>]
44
- def s_texts_exact value
46
+ def texts_exact value
45
47
  xpaths_visible_exact TextView, value
46
48
  end
47
-
48
- # Find all TextViews.
49
- # @return [Array<TextView>]
50
- def e_s_texts
51
- tags TextView
52
- end
53
49
  end # module Android
54
50
  end # module Appium
@@ -12,9 +12,11 @@ module Appium
12
12
  end
13
13
 
14
14
  # Find all EditTexts containing value.
15
+ # If value is omitted, all EditTexts are returned.
15
16
  # @param value [String] the value to search for
16
17
  # @return [Array<EditText>]
17
- def textfields value
18
+ def textfields value=false
19
+ return tags EditText unless value
18
20
  xpaths_visible_contains EditText, value
19
21
  end
20
22
 
@@ -43,11 +45,5 @@ module Appium
43
45
  def textfields_exact value
44
46
  xpaths_visible_exact EditText, value
45
47
  end
46
-
47
- # Find all EditTexts.
48
- # @return [Array<EditText>]
49
- def e_textfields
50
- tags EditText
51
- end
52
48
  end # module Android
53
49
  end # module Appium
@@ -39,6 +39,28 @@ module Appium
39
39
  end
40
40
  end
41
41
 
42
+ # scoped to: text resource-id content-desc
43
+ attributes_values = attributes.values
44
+ id_matches = $driver.lazy_load_strings.select do |key, value|
45
+ attributes_values.include? value
46
+ end
47
+
48
+ string_ids = nil
49
+
50
+ if id_matches && id_matches.length > 0
51
+ space_suffix = ' ' * ' strings.xml: '.length
52
+ string_ids = ''
53
+
54
+ # add first
55
+ string_ids += "#{id_matches.shift[0]}\n"
56
+
57
+ # use padding for remaining values
58
+ # [0] = key, [1] = value
59
+ id_matches.each do |match|
60
+ string_ids += "#{space_suffix}#{match[0]}\n"
61
+ end
62
+ end
63
+
42
64
  string = ''
43
65
  text = attributes['text']
44
66
  desc = attributes['content-desc']
@@ -51,6 +73,7 @@ module Appium
51
73
  string += " desc: #{desc}\n" unless desc.nil?
52
74
  end
53
75
  string += " id: #{id}\n" unless id.nil?
76
+ string += " strings.xml: #{string_ids}" unless string_ids.nil?
54
77
 
55
78
  @result += "\n#{name}\n#{string}" unless attributes.empty?
56
79
  end
@@ -74,10 +97,11 @@ module Appium
74
97
 
75
98
  # Intended for use with console.
76
99
  # Inspects and prints the current page.
77
- # @param class_name [String] the class name to filter on.
78
- # if false (default) then all classes will be inspected
100
+ # @option class [Symbol] the class name to filter on. case insensitive include match.
101
+ # if nil (default) then all classes will be inspected
79
102
  # @return [void]
80
- def page class_name=false
103
+ def page opts={}
104
+ class_name = opts.is_a?(Hash) ? opts.fetch(:class, nil) : opts
81
105
  puts get_android_inspect class_name
82
106
  nil
83
107
  end
@@ -96,17 +120,29 @@ module Appium
96
120
  am_start: pkg + '/' + act)
97
121
  end
98
122
 
99
- # Find by id
100
- # @param id [String] the id to search for
101
- # @return [Element]
102
- def id id
103
- value = resolve_id id
123
+ # @private
124
+ def string_id_xpath id
125
+ value = resolve_id id
104
126
  # If the id doesn't resolve in strings.xml then use it as is
105
127
  # It's probably a resource id which won't be in strings.xml
106
- value = id unless value
128
+ value = id unless value
107
129
  exact = string_visible_exact '*', value
108
130
  contains = string_visible_contains '*', value
109
- xpath "#{exact} | #{contains}"
131
+ "#{exact} | #{contains}"
132
+ end
133
+
134
+ # Find the first matching element by id
135
+ # @param id [String] the id to search for
136
+ # @return [Element]
137
+ def id id
138
+ xpath string_id_xpath id
139
+ end
140
+
141
+ # Find all matching elements by id
142
+ # @param id [String] the id to search for
143
+ # @return [Element]
144
+ def ids id
145
+ xpaths string_id_xpath id
110
146
  end
111
147
 
112
148
  # Find the element of type class_name at matching index.
@@ -134,7 +134,9 @@ module Appium
134
134
 
135
135
  # http://nokogiri.org/Nokogiri/XML/SAX/Document.html
136
136
  def start_element name, attrs = []
137
- @result[name] += 1
137
+ # Count only visible elements. Android is always visible
138
+ element_visible = $driver.device_is_android? ? true : attrs.to_h['visible'] == 'true'
139
+ @result[name] += 1 if element_visible
138
140
  end
139
141
 
140
142
  def formatted_result
@@ -147,7 +149,7 @@ module Appium
147
149
  end
148
150
  end # class CountElements
149
151
 
150
- # Returns a string of class counts.
152
+ # Returns a string of class counts of visible elements.
151
153
  def get_page_class
152
154
  parser = @count_elements_parser ||= Nokogiri::XML::SAX::Parser.new(CountElements.new)
153
155
 
@@ -84,7 +84,7 @@ def patch_webdriver_bridge
84
84
  # path may be nil, session, or not have anything after the session_id.
85
85
  path_str = path
86
86
  path_str = '/' + path_str unless path_str.nil? ||
87
- path_str.length <= 0 || path_str[0] == '/'
87
+ path_str.length <= 0 || path_str[0] == '/'
88
88
  path_match = path.match /.*\h{8}-?\h{4}-?\h{4}-?\h{4}-?\h{12}/
89
89
  path_str = path.sub(path_match[0], '') unless path_match.nil?
90
90
 
@@ -1,5 +1,5 @@
1
1
  module Appium
2
2
  # Version and Date are defined on the 'Appium' module, not 'Appium::Common'
3
- VERSION = '1.0.0' unless defined? ::Appium::VERSION
4
- DATE = '2014-04-29' unless defined? ::Appium::DATE
3
+ VERSION = '2.0.0' unless defined? ::Appium::VERSION
4
+ DATE = '2014-05-14' unless defined? ::Appium::DATE
5
5
  end
@@ -5,19 +5,18 @@ module Appium
5
5
  extend Forwardable
6
6
 
7
7
  NoArgMethods = {
8
- post: {
9
- shake: 'session/:session_id/appium/device/shake',
10
- launch: 'session/:session_id/appium/app/launch',
11
- close_app: 'session/:session_id/appium/app/close',
12
- reset: 'session/:session_id/appium/app/reset',
13
- toggle_airplane_mode: 'session/:session_id/appium/device/toggle_airplane_mode'
14
- },
15
- get: {
16
- current_activity: 'session/:session_id/appium/device/current_activity',
17
- current_context: 'session/:session_id/context',
18
- app_strings: 'session/:session_id/appium/app/strings',
19
- available_contexts: 'session/:session_id/contexts',
20
- }
8
+ post: {
9
+ shake: 'session/:session_id/appium/device/shake',
10
+ launch: 'session/:session_id/appium/app/launch',
11
+ close_app: 'session/:session_id/appium/app/close',
12
+ reset: 'session/:session_id/appium/app/reset',
13
+ toggle_airplane_mode: 'session/:session_id/appium/device/toggle_airplane_mode',
14
+ },
15
+ get: {
16
+ current_activity: 'session/:session_id/appium/device/current_activity',
17
+ current_context: 'session/:session_id/context',
18
+ available_contexts: 'session/:session_id/contexts',
19
+ }
21
20
  }
22
21
 
23
22
  # @!method app_strings
@@ -98,6 +97,13 @@ module Appium
98
97
  pair.each_pair { |command, path| add_endpoint_method command, path, verb }
99
98
  end
100
99
 
100
+ add_endpoint_method(:app_strings, 'session/:session_id/appium/app/strings') do
101
+ def app_strings language=nil
102
+ opts = language ? { language: language } : {}
103
+ execute :app_strings, {}, opts
104
+ end
105
+ end
106
+
101
107
  add_endpoint_method(:lock, 'session/:session_id/appium/device/lock') do
102
108
  def lock(duration)
103
109
  execute :lock, {}, :seconds => duration
@@ -128,9 +134,9 @@ module Appium
128
134
  end
129
135
  end
130
136
 
131
- add_endpoint_method(:current_context=, 'session/:session_id/context') do
132
- def current_context=(context=null)
133
- execute :current_context=, {}, :context => context
137
+ add_endpoint_method(:set_context, 'session/:session_id/context') do
138
+ def set_context(context=null)
139
+ execute :set_context, {}, :name => context
134
140
  end
135
141
  end
136
142
 
@@ -142,7 +148,7 @@ module Appium
142
148
 
143
149
  add_endpoint_method(:key_event, 'session/:session_id/appium/device/keyevent') do
144
150
  def key_event(key, metastate=nil)
145
- args = {keycode: key}
151
+ args = { keycode: key }
146
152
  args[:metastate] = metastate if metastate
147
153
  execute :key_event, {}, args
148
154
  end
@@ -157,7 +163,7 @@ module Appium
157
163
 
158
164
  add_endpoint_method(:complex_find, 'session/:session_id/appium/app/complex_find') do
159
165
  def complex_find(opts)
160
- mode = opts.fetch :mode, false
166
+ mode = opts.fetch :mode, false
161
167
  selectors = opts.fetch :selectors, false
162
168
  raise 'Complex find must have selectors' unless selectors
163
169
  selectors.insert(0, mode) if mode
@@ -172,10 +178,10 @@ module Appium
172
178
  end
173
179
  end
174
180
 
175
- add_endpoint_method(:push_file,'session/:session_id/appium/device/push_file') do
181
+ add_endpoint_method(:push_file, 'session/:session_id/appium/device/push_file') do
176
182
  def push_file(path, filedata)
177
183
  encoded_data = Base64.encode64 filedata
178
- execute :push_file, {}, path: path, data: encoded_data
184
+ execute :push_file, {}, path: path, data: encoded_data
179
185
  end
180
186
  end
181
187
 
@@ -211,7 +217,7 @@ module Appium
211
217
 
212
218
  delegate_driver_method method
213
219
  delegate_from_appium_driver method
214
- end
220
+ end
215
221
 
216
222
  # @private
217
223
  def extend_webdriver_with_forwardable
@@ -303,13 +309,13 @@ module Appium
303
309
  delegate_from_appium_driver(:zoom, Appium::MultiTouch)
304
310
  end
305
311
  end # class << self
306
-
307
- # @!method current_context=
312
+
313
+ # @!method set_context
308
314
  # Change the context to the given context.
309
315
  # @param [String] The context to change to
310
316
  #
311
317
  # ```ruby
312
- # current_context= "NATIVE_APP"
318
+ # set_context "NATIVE_APP"
313
319
  # ```
314
320
 
315
321
  # @!method current_context
@@ -327,13 +333,14 @@ module Appium
327
333
  # ```
328
334
  def within_context(context)
329
335
  existing_context = current_context
336
+ set_context context
330
337
  yield if block_given?
331
- current_context = existing_context
338
+ set_context existing_context
332
339
  end
333
340
 
334
- # Change to the default context. This is equivalent to `current_context= nil`.
341
+ # Change to the default context. This is equivalent to `set_context nil`.
335
342
  def switch_to_default_context
336
- current_context = nil
343
+ set_context nil
337
344
  end
338
345
  end # module Device
339
346
  end # module Appium