Class: TestCentricity::MenuBar

Inherits:
ScreenSection show all
Defined in:
lib/testcentricity_apps/app_elements/menubar.rb

Instance Attribute Summary

Attributes inherited from ScreenSection

#context, #list_index, #locator, #name, #parent, #parent_list

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ScreenSection

button, buttons, checkbox, checkboxes, #click, #disabled?, #double_tap, element, elements, #enabled?, #exists?, #get_locator, #get_name, #height, #hidden?, #identifier, image, images, label, labels, list, lists, #long_press, radio, radios, #scroll_into_view, section, sections, selectlist, selectlists, #send_keys, #set_list_index, #set_parent, switch, switches, #tap, textfield, textfields, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_visible, #width, #x_loc, #y_loc

Methods inherited from BaseScreenSectionObject

#populate_data_fields, #swipe_gesture, trait, #verify_ui_states

Constructor Details

#initialize(name, parent, locator, context) ⇒ MenuBar

Returns a new instance of MenuBar.



9
10
11
12
13
14
15
# File 'lib/testcentricity_apps/app_elements/menubar.rb', line 9

def initialize(name, parent, locator, context)
  super
  @parent = nil
  # define the menu bar item element for the menu bar list object
  list_elements = { list_item: { xpath: '(//XCUIElementTypeMenuBarItem)' } }
  menu_list.define_list_elements(list_elements)
end

Class Method Details

Declare and instantiate a single menu UI Element for this MenuBar object.

Examples:

menu :convert_menu, { xpath: '//XCUIElementTypeMenuBarItem[6]' }

Parameters:

  • element_name (Symbol)

    name of menu object (as a symbol)

  • locator (Hash)

    { locator_strategy: locator_identifier }



28
29
30
# File 'lib/testcentricity_apps/app_elements/menubar.rb', line 28

def self.menu(element_name, locator)
  define_section_element(element_name, TestCentricity::AppElements::AppMenu, locator)
end

Declare and instantiate a collection of menus for this MenuBar object.

Examples:

menus convert_menu: { xpath: '//XCUIElementTypeMenuBarItem[6]' },
      view_menu:    { xpath: '//XCUIElementTypeMenuBarItem[5]' }

Parameters:

  • element_hash (Hash)

    names of menus (as symbol) and locator Hash



39
40
41
# File 'lib/testcentricity_apps/app_elements/menubar.rb', line 39

def self.menus(element_hash)
  element_hash.each_pair { |element_name, locator| menu(element_name, locator) }
end

Instance Method Details

#get_item_countInteger

Return the number of menus in a MenuBar object.

Examples:

num_menus = menu_bar.get_item_count

Returns:

  • (Integer)


49
50
51
# File 'lib/testcentricity_apps/app_elements/menubar.rb', line 49

def get_item_count
  menu_list.get_item_count
end

#get_menubar_item(index) ⇒ String Also known as: get_list_item

Return text caption of menu item at specified index.

Examples:

menubar_item_text = menu_bar.get_menubar_item(3)

Returns:



71
72
73
74
# File 'lib/testcentricity_apps/app_elements/menubar.rb', line 71

def get_menubar_item(index)
  items = get_list_items
  items[index - 1]
end

#get_menubar_itemsArray Also known as: get_list_items

Return array of strings of all menus in a MenuBar object.

Examples:

menu_items = menu_bar.get_menubar_items

Returns:

  • (Array)


59
60
61
# File 'lib/testcentricity_apps/app_elements/menubar.rb', line 59

def get_menubar_items
  menu_list.get_list_items
end

#get_object_typeObject



17
18
19
# File 'lib/testcentricity_apps/app_elements/menubar.rb', line 17

def get_object_type
  :menubar
end