5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/appium_lib_core/device/context.rb', line 5
def self.add_methods
::Appium::Core::Device.add_endpoint_method(:within_context) do
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
end
::Appium::Core::Device.add_endpoint_method(:switch_to_default_context) do
def switch_to_default_context
set_context nil
end
end
::Appium::Core::Device.add_endpoint_method(:current_context) do
def current_context
execute :current_context
end
end
::Appium::Core::Device.add_endpoint_method(:available_contexts) do
def available_contexts
execute(:available_contexts, {}) || []
end
end
::Appium::Core::Device.add_endpoint_method(:set_context) do
def set_context(context = null)
execute :set_context, {}, name: context
end
end
end
|