Module: Appium::Core::Base::Device::Context

Defined in:
lib/appium_lib_core/common/device/context.rb

Instance Method Summary collapse

Instance Method Details

#available_contextsObject



36
37
38
39
# File 'lib/appium_lib_core/common/device/context.rb', line 36

def available_contexts
  # return empty array instead of nil on failure
  execute(:available_contexts, {}) || []
end

#current_contextObject



32
33
34
# File 'lib/appium_lib_core/common/device/context.rb', line 32

def current_context
  execute :current_context
end

#set_context(context = nil) ⇒ Object



41
42
43
# File 'lib/appium_lib_core/common/device/context.rb', line 41

def set_context(context = nil)
  execute :set_context, {}, name: context
end

#within_context(context) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/appium_lib_core/common/device/context.rb', line 20

def within_context(context)
  existing_context = current_context
  set_context context
  if block_given?
    result = yield
    set_context existing_context
    result
  else
    set_context existing_context
  end
end