Sha256: 56bdd9dc42f8e7096e3a429deceee251679e8b1eb5d721a9de0103f6efb96de8

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

require 'base64'

module Appium
  module Core
    module Android
      module Device
        module Clipboard
          def self.add_methods
            ::Appium::Core::Device.add_endpoint_method(:get_clipboard) do
              def get_clipboard(content_type: :plaintext)
                unless ::Appium::Core::Device::Clipboard::CONTENT_TYPE.member?(content_type)
                  raise "content_type should be #{::Appium::Core::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, label: nil)
                unless ::Appium::Core::Device::Clipboard::CONTENT_TYPE.member?(content_type)
                  raise "content_type should be #{::Appium::Core::Device::Clipboard::CONTENT_TYPE}"
                end

                params = {
                  contentType: content_type,
                  content: Base64.encode64(content)
                }
                params[:label] = label unless label.nil?

                execute(:set_clipboard, {}, params)
              end
            end
          end
        end # module Clipboard
      end # module Device
    end # module Android
  end # module Core
end # module Appium

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appium_lib_core-1.7.2 lib/appium_lib_core/android/device/clipboard.rb
appium_lib_core-1.7.1 lib/appium_lib_core/android/device/clipboard.rb
appium_lib_core-1.7.0 lib/appium_lib_core/android/device/clipboard.rb