Module: Appium::Core::Android::Device::Network

Defined in:
lib/appium_lib_core/android/device/network.rb

Class Method Summary collapse

Class Method Details

.add_methodsObject



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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/appium_lib_core/android/device/network.rb', line 20

def self.add_methods
  ::Appium::Core::Device.add_endpoint_method(:get_network_connection) do
    def get_network_connection
      ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: getConnectivity' extension instead"

      execute :get_network_connection
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:toggle_wifi) do
    def toggle_wifi
      ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"

      execute :toggle_wifi
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:toggle_data) do
    def toggle_data
      ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"

      execute :toggle_data
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:set_network_connection) do
    def set_network_connection(mode)
      ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"

      # same as ::Selenium::WebDriver::DriverExtensions::HasNetworkConnection
      # But this method accept number
      connection_type = { airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0 }
      type = connection_type.key?(mode) ? connection_type[mode] : mode.to_i

      execute :set_network_connection, {}, type: type
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:toggle_airplane_mode) do
    def toggle_airplane_mode
      ::Appium::Logger.warn "[DEPRECATION] Please use 'mobile: setConnectivity' extension instead"

      execute :toggle_airplane_mode
    end
    alias_method :toggle_flight_mode, :toggle_airplane_mode
  end
end