class LdsGrid

Public Class Methods

new(browser, idBlock, idScreen=nil) click to toggle source

constructor

Calls superclass method LdsBlock::new
# File lib/TNR360/components/lds_grid.rb, line 20
def initialize(browser, idBlock, idScreen=nil)
  super(browser, idBlock, idScreen)
  update
  @exists
end

Public Instance Methods

addLine(*args) click to toggle source

Add action in a grid

# 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_s() click to toggle source
# File lib/TNR360/components/lds_grid.rb, line 294
def allColumns_to_s
  if (@allColumns!=nil)
    @allColumns.each { |value| puts value }
  end
end
checkSelectedLine(lineIndex) click to toggle source
# 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
check_editable() click to toggle source

check if editable grid or not

# 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_paginated() click to toggle source

check if paginated grid or not

# File lib/TNR360/components/lds_grid.rb, line 33
def check_paginated
  @paginated_grid=@current_element.class_name.include?"paging-remote"
end
clickFkInGrid(lineIndex, idColumn) click to toggle source

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

# 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
clickRefresh() click to toggle source
# File lib/TNR360/components/lds_grid.rb, line 243
def clickRefresh
  @current_element.div(:class, "std-fieldset-bbar").img(:index => 4).click
end
columnValues_to_s() click to toggle source
# 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
column_to_s() click to toggle source
# 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
deleteLine(lineIndex) click to toggle source

Delete action in a grid

# 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) click to toggle source
# 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) click to toggle source

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

# 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) click to toggle source
# 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) click to toggle source
# 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
extractDisplayedColumns() click to toggle source

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

# 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) click to toggle source

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

# 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?() click to toggle source
# File lib/TNR360/components/lds_grid.rb, line 325
def getCellEditable?
  @isCellEditable
end
getCellLines(idColumn, cellValue) click to toggle source
# 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
getCellValue() click to toggle source
# File lib/TNR360/components/lds_grid.rb, line 321
def getCellValue
  @cellValue
end
getEditable?() click to toggle source
# File lib/TNR360/components/lds_grid.rb, line 313
def getEditable?
  @editable_grid
end
getPaginated?() click to toggle source
# File lib/TNR360/components/lds_grid.rb, line 309
def getPaginated?
  @paginated_grid
end
goFirst() click to toggle source

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

# 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
goLast() click to toggle source
# 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
goNext() click to toggle source
# 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
goPrevious() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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?() click to toggle source
# File lib/TNR360/components/lds_grid.rb, line 317
def isSelectedLine?
  @check_selected_line
end
lineDoubleClick(lineIndex) click to toggle source

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

# 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) click to toggle source

Modify a cell in a grid

# 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) click to toggle source
# 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_s() click to toggle source

print object

Calls superclass method LdsBlock#to_s
# 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

Private Instance Methods

update() click to toggle source
Calls superclass method LdsBlock#update
# File lib/TNR360/components/lds_grid.rb, line 26
def update
  super
  check_paginated
  check_editable
end