Class: Honeydew::Device

Inherits:
Object
  • Object
show all
Includes:
DeviceActions, DeviceLogFormatter, DeviceMatchers
Defined in:
lib/honeydew/device.rb

Constant Summary collapse

ServerTimeoutError =
Class.new(Timeout::Error)
ActionFailedError =
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DeviceMatchers

#child_count_assertion, #has_app_installed?, #has_app_installed_in_data?, #has_button?, #has_child_count?, #has_child_count_greater_than?, #has_edit_text?, #has_element_with_description?, #has_element_with_nested_text?, #has_regex_match?, #has_settings_menu_item?, #has_text?, #has_text_disappear?, #has_textview_text?, #has_textview_with_text_and_description?, #is_option_in_setting_disabled?, #is_option_in_setting_enabled?

Methods included from DeviceActions

#click_button, #click_button_and_wait, #click_check_box, #click_checked_text_view, #click_element, #click_element_and_wait, #click_text, #click_text_and_wait, #fill_in, #fill_in_by_index, #fill_in_by_label, #launch_application, #launch_home, #launch_settings_app, #launch_settings_item, #long_click_element, #long_click_text, #press_back, #press_enter, #scroll_to_text, #sleep, #unlock, #wake_up

Methods included from DeviceCommands

#adb, #clear_app_data, #clear_directory, #device_endpoint, #dump_window_hierarchy, #forwarding_port, #honeydew_server_file, #honeydew_server_package, #install_app, #is_app_installed?, #is_app_installed_in_data?, #launch_settings, #reboot, #start_automation_server, #start_honeydew_server, #take_screenshot, #terminate_honeydew_server, #uninstall_app

Constructor Details

#initialize(serial) ⇒ Device

Returns a new instance of Device.



18
19
20
21
22
23
24
25
26
27
# File 'lib/honeydew/device.rb', line 18

def initialize(serial)
  @serial = serial

  unless Honeydew.attached_devices.include?(@serial)
    raise ArgumentError, "No device with serial #{@serial} attached"
  end

  @port = Honeydew.config.obtain_new_port
  start_honeydew_server
end

Instance Attribute Details

#portObject (readonly)

Returns the value of attribute port.



16
17
18
# File 'lib/honeydew/device.rb', line 16

def port
  @port
end

#serialObject (readonly)

Returns the value of attribute serial.



16
17
18
# File 'lib/honeydew/device.rb', line 16

def serial
  @serial
end

Instance Method Details

#using_timeout(timeout) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/honeydew/device.rb', line 29

def using_timeout timeout
  old_timeout = Honeydew.config.timeout
  Honeydew.config.timeout = timeout
  yield
ensure
  Honeydew.config.timeout = old_timeout
end