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

Included in:
Bridge::MJSONWP, Bridge::W3C
Defined in:
lib/appium_lib_core/common/device/context.rb

Instance Method Summary collapse

Instance Method Details

#available_contextsObject


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

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

#current_contextObject


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

def current_context
  execute :current_context
end

#set_context(context = null) ⇒ Object


45
46
47
# File 'lib/appium_lib_core/common/device/context.rb', line 45

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

#switch_to_default_contextObject


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

def switch_to_default_context
  set_context nil
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