Class: TestCentricity::ListElement

Inherits:
UIElement show all
Defined in:
lib/testcentricity_web/web_elements/list_element.rb

Direct Known Subclasses

ListButton, ListCheckBox, ListRadio

Constant Summary

Constants inherited from UIElement

UIElement::CSS_SELECTORS, UIElement::XPATH_SELECTORS

Instance Attribute Summary collapse

Attributes inherited from UIElement

#alt_locator, #context, #locator, #locator_type, #name, #original_style, #parent, #type

Instance Method Summary collapse

Methods inherited from UIElement

#aria_autocomplete, #aria_busy?, #aria_checked?, #aria_colcount, #aria_controls, #aria_describedby, #aria_disabled?, #aria_expanded?, #aria_haspopup?, #aria_hidden?, #aria_invalid?, #aria_keyshortcuts, #aria_label, #aria_labelledby, #aria_live, #aria_modal?, #aria_multiline?, #aria_multiselectable?, #aria_orientation, #aria_pressed?, #aria_readonly?, #aria_required?, #aria_roledescription, #aria_rowcount, #aria_selected?, #aria_sort, #aria_valuemax, #aria_valuemin, #aria_valuenow, #aria_valuetext, #clear_alt_locator, #click_at, #content_editable?, #count, #disabled?, #displayed?, #double_click, #drag_and_drop, #drag_by, #enabled?, #find_element, #focused?, #get_attribute, #get_locator, #get_locator_type, #get_name, #get_native_attribute, #get_object_type, #get_siebel_object_type, #height, #hidden?, #highlight, #hover, #hover_at, #inspect, #invoke_siebel_dialog, #obscured?, #right_click, #role, #scroll_to, #send_keys, #set, #set_alt_locator, #set_locator_type, #style, #tabindex, #title, #unhighlight, #verify_value, #visible?, #wait_until_exists, #wait_until_gone, #wait_until_hidden, #wait_until_value_changes, #wait_until_value_is, #wait_until_visible, #width, #x, #y

Constructor Details

#initialize(name, parent, locator, context, list, proxy = nil) ⇒ ListElement

Returns a new instance of ListElement.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/testcentricity_web/web_elements/list_element.rb', line 6

def initialize(name, parent, locator, context, list, proxy = nil)
  @name            = name
  @parent          = parent
  @context         = context
  @alt_locator     = nil
  @list            = list
  @element_locator = locator

  set_locator_type(@list.get_locator)

  if locator.nil?
    @locator = list.get_list_row_locator('ROW_SPEC')
  else
    @locator = case @locator_type
               when :xpath
                 "#{list.get_list_row_locator('ROW_SPEC')}/#{@element_locator}"
               when :css
                 "#{list.get_list_row_locator('ROW_SPEC')} > #{@element_locator}"
               end
  end
end

Instance Attribute Details

#element_locatorObject

Returns the value of attribute element_locator.



4
5
6
# File 'lib/testcentricity_web/web_elements/list_element.rb', line 4

def element_locator
  @element_locator
end

#listObject

Returns the value of attribute list.



3
4
5
# File 'lib/testcentricity_web/web_elements/list_element.rb', line 3

def list
  @list
end

Instance Method Details

#click(row) ⇒ Object



33
34
35
36
37
# File 'lib/testcentricity_web/web_elements/list_element.rb', line 33

def click(row)
  obj, = find_list_element(row)
  list_object_not_found_exception(obj, @type, row)
  obj.click
end

#exists?(row) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/testcentricity_web/web_elements/list_element.rb', line 28

def exists?(row)
  obj, = find_list_element(row)
  obj != nil
end

#find_list_element(row, visible = true) ⇒ Object



52
53
54
55
# File 'lib/testcentricity_web/web_elements/list_element.rb', line 52

def find_list_element(row, visible = true)
  set_alt_locator("#{@locator.gsub('ROW_SPEC', row.to_s)}")
  find_element(visible)
end

#get_value(row, visible = true) ⇒ Object Also known as: get_caption



39
40
41
42
43
44
45
46
47
48
# File 'lib/testcentricity_web/web_elements/list_element.rb', line 39

def get_value(row, visible = true)
  obj, = find_list_element(row, visible)
  list_object_not_found_exception(obj, @type, row)
  case obj.tag_name.downcase
    when 'input', 'select', 'textarea'
      obj.value
    else
      obj.text
  end
end

#list_object_not_found_exception(obj, obj_type, row) ⇒ Object



57
58
59
# File 'lib/testcentricity_web/web_elements/list_element.rb', line 57

def list_object_not_found_exception(obj, obj_type, row)
  object_not_found_exception(obj, "Row #{row} #{obj_type}")
end