Class: LdsGrid

Inherits:
LdsBlock show all
Defined in:
lib/TNR360/components/lds_grid.rb

Instance Method Summary collapse

Methods inherited from LdsBlock

#collapse, #elementExists?, #expand, #extractAreas, #findElement, #getAreas, #getElement, #getIdBlock, #getIdScreen, #getTitle, #getType, #hasMultipleAreas?, #isCollapsed?, #isCollapsible?, #isExist?, #isScreenDisplayed, #isVisible?, #refresh, #reverse_collapse

Constructor Details

#initialize(browser, idBlock, idScreen = nil) ⇒ LdsGrid

constructor



20
21
22
23
24
# File 'lib/TNR360/components/lds_grid.rb', line 20

def initialize(browser, idBlock, idScreen=nil)
  super(browser, idBlock, idScreen)
  update
  @exists
end

Instance Method Details

#addLine(*args) ⇒ Object

Add action in a grid



248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/TNR360/components/lds_grid.rb', line 248

def addLine (*args)
  @current_element.div(:class, "std-fieldset-tbar").table(:xpath => "//table[contains(@id"",'"+"add"+"')]").when_present.click
  args.each do |arg_item|
  @current_element.div(:class,"x-form-field-wrap  x-spinner-field fwk-number x-component").text_field.set arg_item
  @browser.send_keys :tab
  # def sub_method(idScreen,*args)
  #   args.each do |arg_item|
  #     puts arg_item.inspect
  #     puts arg_item.class.inspect
  #   end
   end
end

#allColumns_to_sObject



294
295
296
297
298
# File 'lib/TNR360/components/lds_grid.rb', line 294

def allColumns_to_s
  if (@allColumns!=nil)
    @allColumns.each { |value| puts value }
  end
end

#check_editableObject

check if editable grid or not



37
38
39
# File 'lib/TNR360/components/lds_grid.rb', line 37

def check_editable
  @editable_grid=@current_element.div(:class, "std-fieldset-bwrap").div(:class, "std-fieldset-tbar").exists?
end

#check_paginatedObject

check if paginated grid or not



33
34
35
# File 'lib/TNR360/components/lds_grid.rb', line 33

def check_paginated
  @paginated_grid=@current_element.class_name.include?"paging-remote"
end

#checkSelectedLine(lineIndex) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/TNR360/components/lds_grid.rb', line 95

def checkSelectedLine (lineIndex)
  #@selected_line= @current_element.div(:class,"std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => lineIndex-1).parent.class_name.include? "selected"
  @line= extractLine lineIndex
  @check_selected_line=@line.class_name.include? "selected"
  puts "\nIsSelectedLine : "+ bool_no_null(@check_selected_line.to_s)

end

#clickFkInGrid(lineIndex, idColumn) ⇒ Object

***************************Cell Actions methods****************************



175
176
177
178
179
180
181
182
183
184
185
# File 'lib/TNR360/components/lds_grid.rb', line 175

def clickFkInGrid (lineIndex, idColumn)
  @cell=extractCellByLineAndColumnIndex lineIndex, idColumn
  if (@cell!=nil)
    @cell.click
    sleep($wait_time)
  end
  if (!@browser.div(:id => @idBlock).visible?)
    @fkClickCell=true
  end
  puts "\nFkClick :"+ bool_no_null(@fkClickCell.to_s)
end

#clickRefreshObject



243
244
245
# File 'lib/TNR360/components/lds_grid.rb', line 243

def clickRefresh
  @current_element.div(:class, "std-fieldset-bbar").img(:index => 4).click
end

#column_to_sObject



300
301
302
303
304
305
306
# File 'lib/TNR360/components/lds_grid.rb', line 300

def column_to_s
  if (@columns != nil)
    @columns.each do |column|
      column.to_s
    end
  end
end

#columnValues_to_sObject



286
287
288
289
290
291
# File 'lib/TNR360/components/lds_grid.rb', line 286

def columnValues_to_s
  if (@columnValues!=nil)
    puts "\n*****Values of column : "+ no_null(@labelColumn) + "*****"
    @columnValues.each { |value| puts value }
  end
end

#deleteLine(lineIndex) ⇒ Object

Delete action in a grid



262
263
264
265
266
# File 'lib/TNR360/components/lds_grid.rb', line 262

def deleteLine (lineIndex)
  extractLine lineIndex
  selectLine lineIndex
  @current_element.div(:class, "std-fieldset-tbar").table(:xpath => "//table[contains(@id,'"+"remove"+"')]").when_present.click
end

#extractAllColumns(columnId) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/TNR360/components/lds_grid.rb', line 56

def extractAllColumns columnId
  count=0
  @allColumns=Array.new
  @column=LdsColumn.new(@browser, columnId, self, count)
  @column.displayColumns (@column.getLabel)
  columnsNbr=@browser.div(:id, "Payment-change-visibility-menu").div(:class, "x-menu-list").as.length
  while count< columnsNbr
    @allColumns<< @browser.div(:id, "Payment-change-visibility-menu").div(:class, "x-menu-list").a(:index => count).class_name.split("-").last
    count+=1
  end
end

#extractCellByLineAndColumnIndex(lineIndex, idColumn) ⇒ Object

*******************************Cell methods**********************



130
131
132
133
134
135
136
# File 'lib/TNR360/components/lds_grid.rb', line 130

def extractCellByLineAndColumnIndex (lineIndex, idColumn)
  if @current_element.div(:class, "std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => lineIndex-1).td(:xpath => "//td[contains(@class,'"+idColumn+"')]", :index => lineIndex).exists?
    @current_element.div(:class, "std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => lineIndex-1).td(:xpath => "//td[contains(@class,'"+idColumn+"')]", :index => lineIndex)
  else
    puts "Cell not found"
  end
end

#extractCellValue(lineIndex, idColumn) ⇒ Object



138
139
140
141
142
143
144
# File 'lib/TNR360/components/lds_grid.rb', line 138

def extractCellValue (lineIndex, idColumn)
  @cell=extractCellByLineAndColumnIndex lineIndex, idColumn
  if (@cell!=nil)
    @cellValue=@cell.text
  end
  puts "\nCell value : "+ no_null(@cellValue)
end

#extractColumnValues(idColumn) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/TNR360/components/lds_grid.rb', line 68

def extractColumnValues (idColumn)
  lines=@current_element.div(:class, "std-fieldset-bwrap").div(:class, "x-grid3-body").tables.length
  if (lines!=0)
    ind =1
    @columnValues=Array.new
    @labelColumn= @current_element.div(:class, "std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => 0).td(:xpath => "//td[contains(@class,'"+idColumn+"')]", :index => 0).text
    while ind <= lines
      @columnValues << @current_element.div(:class, "std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => ind-1).td(:xpath => "//td[contains(@class,'"+idColumn+"')]", :index => ind).text
      #@current_element.div(:class, "std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => lineIndex).td(:xpath => "//td[contains(@class,'"+idColumn+"')]", :index => lineIndex)
      ind +=1
    end
  else
    puts "grid is empty"
  end
end

#extractDisplayedColumnsObject

*************************column methods****************



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/TNR360/components/lds_grid.rb', line 43

def extractDisplayedColumns
  count=1
  @columns=Array.new
  while count <= @current_element.div(:class, "std-fieldset-bwrap").tr(:index => 0).tds.length
    #iterate through list of columns
    @current_element.div(:class, "std-fieldset-bwrap").tr(:index => 0).tds.each do |column|
      @columns << LdsColumn.new(@browser, column.class_name.split("-").last, self, count)
      count +=1
    end
  end
  puts column_to_s
end

#extractLine(lineIndex) ⇒ Object

***************************line methods******************



85
86
87
88
89
90
91
92
93
# File 'lib/TNR360/components/lds_grid.rb', line 85

def extractLine (lineIndex)
  #iterate through number of lines
  if @current_element.div(:class, "std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => lineIndex-1).exists?
    @current_element.div(:class, "std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => lineIndex-1).parent
  else
    puts "Line not found"
  end

end

#getCellEditable?Boolean

Returns:

  • (Boolean)


325
326
327
# File 'lib/TNR360/components/lds_grid.rb', line 325

def getCellEditable?
  @isCellEditable
end

#getCellLines(idColumn, cellValue) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/TNR360/components/lds_grid.rb', line 146

def getCellLines (idColumn, cellValue)
  extractColumnValues idColumn
  @lineCell=Array.new
  if (@columnValues != nil)
    i=1
    @columnValues.each do |column|
      if column==cellValue
        @lineCell<< i
      end
      i+=1
    end
  end
  if (@lineCell!=nil)
    puts "\n*****Lines that contain : "+ no_null(cellValue) + "*****"
    @lineCell.each { |value| puts value }
  end
end

#getCellValueObject



321
322
323
# File 'lib/TNR360/components/lds_grid.rb', line 321

def getCellValue
  @cellValue
end

#getEditable?Boolean

Returns:

  • (Boolean)


313
314
315
# File 'lib/TNR360/components/lds_grid.rb', line 313

def getEditable?
  @editable_grid
end

#getPaginated?Boolean

Returns:

  • (Boolean)


309
310
311
# File 'lib/TNR360/components/lds_grid.rb', line 309

def getPaginated?
  @paginated_grid
end

#goFirstObject

******************************Grid Actions**********************



189
190
191
192
193
194
195
196
197
# File 'lib/TNR360/components/lds_grid.rb', line 189

def goFirst
  @current_element.div(:class, "std-fieldset-bbar").img(:index => 0).click
  #sleep($large_wait_time)
  pageNumber=@current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 4).text_field.when_present($large_wait_time).value
  if (pageNumber.to_i==1)
    @isFirst=true
  end
  puts "\nIsFirstPage : "+ bool_no_null(@isFirst.to_s)
end

#goLastObject



221
222
223
224
225
226
227
228
229
230
# File 'lib/TNR360/components/lds_grid.rb', line 221

def goLast
  lastPageNumber=@current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 5).div(:index => 0).text.split(" ").last
  @current_element.div(:class, "std-fieldset-bbar").img(:index => 3).click
  #sleep($large_wait_time)
  newPageNumber=@current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 4).text_field.when_present($large_wait_time).value
  if (newPageNumber.to_i==lastPageNumber.to_i)
    @isLast=true
  end
  puts "\nIsLastPage : "+ bool_no_null(@isLast.to_s)
end

#goNextObject



210
211
212
213
214
215
216
217
218
219
# File 'lib/TNR360/components/lds_grid.rb', line 210

def goNext
  pageNumber=@current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 4).text_field.value
  @current_element.div(:class, "std-fieldset-bbar").img(:index => 2).click
  #sleep($large_wait_time)
  newPageNumber=@current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 4).text_field.when_present($large_wait_time).value
  if (newPageNumber.to_i==pageNumber.to_i+1)
    @isNext=true
  end
  puts "\nIsNextPage : "+ bool_no_null(@isNext.to_s)
end

#goPreviousObject



199
200
201
202
203
204
205
206
207
208
# File 'lib/TNR360/components/lds_grid.rb', line 199

def goPrevious
  pageNumber=@current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 4).text_field.value
  @current_element.div(:class, "std-fieldset-bbar").img(:index => 1).click
  #sleep($large_wait_time)
  newPageNumber=@current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 4).text_field.when_present($large_wait_time).value
  if (newPageNumber.to_i==pageNumber.to_i-1)
    @isPrevious=true
  end
  puts "\nIsPreviousPage : "+ bool_no_null(@isPrevious.to_s)
end

#goToPage(pageNbr) ⇒ Object



232
233
234
235
236
237
238
239
240
241
# File 'lib/TNR360/components/lds_grid.rb', line 232

def goToPage pageNbr
  @current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 4).text_field.set pageNbr
  @browser.send_keys :return
  #sleep($wait_time)
  newPageNumber=@current_element.div(:class, "std-fieldset-bbar").td(:class => "x-toolbar-cell", :index => 4).text_field.when_present($wait_time).value
  if (newPageNumber.to_i==pageNbr)
    @goToPageSuccess=true
  end
  puts "\nGoToPageSuccess : "+ bool_no_null(@goToPageSuccess.to_s)
end

#isCellEditable?(lineIndex, idColumn) ⇒ Boolean

Returns:

  • (Boolean)


164
165
166
167
168
169
170
171
172
# File 'lib/TNR360/components/lds_grid.rb', line 164

def isCellEditable? (lineIndex, idColumn)
  @cell=extractCellByLineAndColumnIndex lineIndex, idColumn
  if (@cell!=nil)
    if (@cell.class_name.include? "editable")
      @isCellEditable=true
    end
  end
  puts "\nCellEditable :"+ bool_no_null(@isCellEditable.to_s)
end

#isSelectedLine?Boolean

Returns:

  • (Boolean)


317
318
319
# File 'lib/TNR360/components/lds_grid.rb', line 317

def isSelectedLine?
  @check_selected_line
end

#lineDoubleClick(lineIndex) ⇒ Object

********************************line Actions methods**************



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/TNR360/components/lds_grid.rb', line 111

def lineDoubleClick (lineIndex)
  #@selected_line= @current_element.div(:class,"std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => lineIndex-1).parent.class_name.include? "selected"
  @line= extractLine lineIndex
  if (@line!=nil)
    #if firefox, do the double click trick
    custom_double_click @browser , @line
    sleep($wait_time)
  end

  if (!@browser.div(:id => @idBlock).visible?)
    @doubleClickLine=true
  end

  puts "\nDoubleClick : "+ bool_no_null(@doubleClickLine.to_s)
end

#modifyCell(lineIndex, columnId, newValue) ⇒ Object

Modify a cell in a grid



269
270
271
272
273
274
# File 'lib/TNR360/components/lds_grid.rb', line 269

def modifyCell(lineIndex, columnId, newValue)
  @cellToModify=extractCellByLineAndColumnIndex lineIndex, columnId
  custom_double_click @browser , @cellToModify
  @cellToModify.div(:class,"fwk-weekDaysListGrid-dayName").send_keys newValue
  @browser.send_keys :return
end

#selectLine(lineIndex) ⇒ Object



103
104
105
106
107
108
# File 'lib/TNR360/components/lds_grid.rb', line 103

def selectLine (lineIndex)
  #@selected_line= @current_element.div(:class,"std-fieldset-bwrap").div(:class, "x-grid3-body").table(:index => lineIndex-1).parent.class_name.include? "selected"
  @line= extractLine lineIndex
  @line.click
  checkSelectedLine lineIndex
end

#to_sObject

print object



277
278
279
280
281
282
283
# File 'lib/TNR360/components/lds_grid.rb', line 277

def to_s
  super.to_s +
      "\n***** Grid *****"+
      "\nIsPaginated : "+ bool_no_null(@paginated_grid.to_s)+
      "\nIsEditable : "+ bool_no_null(@editable_grid.to_s)+
      "\n**********"
end