Method: Appium::Core::Android::Device.extended

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

.extended(_mod) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/appium_lib_core/android/device.rb', line 250

def extended(_mod)
  ::Appium::Core::Device.extend_webdriver_with_forwardable

  ::Appium::Core::Device.add_endpoint_method(:open_notifications) do
    def open_notifications
      execute_script 'mobile:openNotifications', {}
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:current_activity) do
    def current_activity
      execute_script 'mobile:getCurrentActivity', {}
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:current_package) do
    def current_package
      execute_script 'mobile:getCurrentPackage', {}
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:get_system_bars) do
    def get_system_bars
      execute_script 'mobile:getSystemBars', {}
    end
  end
  # as alias to get_system_bars
  ::Appium::Core::Device.add_endpoint_method(:system_bars) do
    def system_bars
      execute_script 'mobile:getSystemBars', {}
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:toggle_location_services) do
    def toggle_location_services
      execute_script 'mobile:toggleGps', {}
    end
  end

  # Android, Override included method in bridge
  ::Appium::Core::Device.add_endpoint_method(:hide_keyboard) do
    def hide_keyboard(_close_key = nil)
      execute_script 'mobile:hideKeyboard', {}
    end
  end

  # Android, Override included method in bridge
  ::Appium::Core::Device.add_endpoint_method(:background_app) do
    def background_app(duration = 0)
      execute_script 'mobile:backgroundApp', { seconds: duration }
    end
  end

  ::Appium::Core::Device.add_endpoint_method(:execute_cdp) do
    # SeleniumWebdriver could already define this method
    return if method_defined? :execute_cdp

    def execute_cdp(cmd, **params)
      execute :chrome_send_command, {}, { cmd: cmd, params: params }
    end
  end

  Screen.add_methods
  Performance.add_methods
  Clipboard.add_methods
  Emulator.add_methods
  Authentication.add_methods
end