Class: SK::KFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/kendo.rb

Instance Method Summary collapse

Constructor Details

#initialize(n) ⇒ KFilter

Returns a new instance of KFilter.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/kendo.rb', line 90

def initialize(n)
  @filter = nil # in case of error    
  # first check that the current page has a kendo grid
  grid = SK::KGrid.new()
  return if ! grid 
  # then work our way throught the page/grid...
  # list of all the column headers; this is a little
  # fragile if the page has other tables before the grid
  th_list = SK::Browser.all({tag_name: 'th'})
  return if !th_list
  return if th_list.length < n
  header = th_list[n] # the nth header for the column
  # puts "attribute = #{header.attribute('data-field')}"
  @filter = header.find_element({class: 'k-grid-filter'})
  # puts "find filter = #{@filter}"
end

Instance Method Details

#clearObject

pause 1



111
112
113
114
115
116
# File 'lib/kendo.rb', line 111

def clear
  buttons = SK::Browser.all({tag_name: 'button'})
  button = buttons.find { |el| el.text == 'Clear' } 
  button.click if button
  sleep 1
end

#clickObject

puts “find filter = #@filter”



106
107
108
109
110
# File 'lib/kendo.rb', line 106

def click
  # puts "click filter = #{@filter}"
  @filter.click() # makes AC it visible
  # pause 1
end

#select(value) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/kendo.rb', line 117

def select(value)
  containers = SK::Browser.all({class: 'k-animation-container'})
  container = containers.find { |c| c.displayed? }
  sleep 1 # to find the textbox???
  textbox = container.find_element({class: 'k-textbox'})
  trace "filter's textbox is not visisble" unless textbox.displayed?
  textbox.send_keys(value)    
  button = container.find_element({class: 'k-primary'})
  button.click()
  sleep 1
end