22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/appium_lib_core/ios/device/clipboard.rb', line 22
def self.add_methods
::Appium::Core::Device.add_endpoint_method(:get_clipboard) do
def get_clipboard(content_type: :plaintext)
unless ::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE.member?(content_type)
raise ::Appium::Core::Error::ArgumentError,
"content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
end
params = { contentType: content_type }
data = execute(:get_clipboard, {}, params)
Base64.decode64 data
end
end
::Appium::Core::Device.add_endpoint_method(:set_clipboard) do
def set_clipboard(content:, content_type: :plaintext)
unless ::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE.member?(content_type)
raise ::Appium::Core::Error::ArgumentError,
"content_type should be #{::Appium::Core::Base::Device::Clipboard::CONTENT_TYPE}"
end
params = {
contentType: content_type,
content: Base64.strict_encode64(content)
}
execute(:set_clipboard, {}, params)
end
end
end
|