Skip to content

Commit 6afc071

Browse files
committed
Change current_context= to set_context.
current_context= would only work with self, eg `self.current_context=`, which makes it stand out in the API. It also was sending the wrong parameters, changed from sending :context to :name
1 parent 7088169 commit 6afc071

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

android_tests/lib/android/specs/common/device.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@
4040
wait { current_context.must_equal 'NATIVE_APP' }
4141
end
4242

43-
t 'current_context=' do
43+
t 'set_context' do
4444
wait do
45-
current_context= 'WEBVIEW'
46-
current_context.must_equal 'WEBVIEW'
45+
scroll_to "Views"
46+
last_s_text.click
47+
scroll_to 'WebView'
48+
last_s_text.click
49+
set_context 'WEBVIEW'
50+
current_context.must_equal 'WEBVIEW_1'
4751
end
4852
end
4953

lib/appium_lib/device/device.rb

+9-8
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ def background_app(duration)
128128
end
129129
end
130130

131-
add_endpoint_method(:current_context=, 'session/:session_id/context') do
132-
def current_context=(context=null)
133-
execute :current_context=, {}, :context => context
131+
add_endpoint_method(:set_context, 'session/:session_id/context') do
132+
def set_context(context=null)
133+
execute :set_context, {}, :name => context
134134
end
135135
end
136136

@@ -304,12 +304,12 @@ def multi_touch(actions)
304304
end
305305
end # class << self
306306

307-
# @!method current_context=
307+
# @!method set_context
308308
# Change the context to the given context.
309309
# @param [String] The context to change to
310310
#
311311
# ```ruby
312-
# current_context= "NATIVE_APP"
312+
# set_context "NATIVE_APP"
313313
# ```
314314

315315
# @!method current_context
@@ -327,13 +327,14 @@ def multi_touch(actions)
327327
# ```
328328
def within_context(context)
329329
existing_context = current_context
330+
set_context context
330331
yield if block_given?
331-
current_context = existing_context
332+
set_context existing_context
332333
end
333334

334-
# Change to the default context. This is equivalent to `current_context= nil`.
335+
# Change to the default context. This is equivalent to `set_context nil`.
335336
def switch_to_default_context
336-
current_context = nil
337+
set_context nil
337338
end
338339
end # module Device
339340
end # module Appium

0 commit comments

Comments
 (0)