Class: SK::KGrid

Inherits:
KElement show all
Defined in:
lib/kendo.rb

Instance Method Summary collapse

Methods inherited from KElement

#el, #exists?, #html, #text

Constructor Details

#initialize(locator = {id: 'grid'}) ⇒ KGrid

Returns a new instance of KGrid.



42
43
44
# File 'lib/kendo.rb', line 42

def initialize(locator={id: 'grid'})
  super(SK::Browser.find(locator))
end

Instance Method Details

#first_page_buttonObject



65
66
67
# File 'lib/kendo.rb', line 65

def first_page_button
  self.grid.find_element({class: 'k-pager-first'})
end

#gridObject



45
46
47
# File 'lib/kendo.rb', line 45

def grid
  el
end

#items_countObject



52
53
54
55
56
57
58
# File 'lib/kendo.rb', line 52

def items_count()
  return 0 unless self.grid
  return 0 unless self.items_label
  # trace "*** items label = #{self.items_label.text}"
  count = /(\d*) items/.match(self.items_label.text)[1].to_i
  return count
end

#items_labelObject



48
49
50
51
# File 'lib/kendo.rb', line 48

def items_label()
  return nil unless grid
  self.grid.find_element({class: 'k-pager-info'})
end

#last_page_buttonObject



62
63
64
# File 'lib/kendo.rb', line 62

def last_page_button
  self.grid.find_element({class: 'k-pager-last'})
end

#next_page_buttonObject



73
74
75
76
77
# File 'lib/kendo.rb', line 73

def next_page_button
  # there is an easily identifiable span inside the button
  span = self.grid.find_element({class: 'k-i-arrow-e'})
  span.find_element({xpath: '..'})
end

#pages_countObject



59
60
61
# File 'lib/kendo.rb', line 59

def pages_count
  last_page_button.attribute('data-page').to_i
end

#prev_page_buttonObject



68
69
70
71
72
# File 'lib/kendo.rb', line 68

def prev_page_button
  # there is an easily identifiable span inside the button
  span = self.grid.find_element({class: 'k-i-arrow-w'})
  span.find_element({xpath: '..'})
end

#row(n) ⇒ Object



83
84
85
# File 'lib/kendo.rb', line 83

def row(n)
  SK::KRow.new(self.rows[n])
end

#rowsObject



78
79
80
81
82
# File 'lib/kendo.rb', line 78

def rows
  set = self.grid.find_elements({tag_name: 'tr'})
  # trace "wt grid rows length = #{set.length}"
  set
end