March 03, 2011

Basic API for BorderLess table



Here is basic API for Borderless tables:
=====================================

boolean Exists (number nTimeOut optional) // Tells the presence of table at the declared boderless level (0 to 1)

list of list of string GetTableData (boolean bIncludeEmptyCells optional) // equal to GetRowRangeText

integer GetRowCount ( )

boolean DoesKeyExists (String sKey, int iSearchColIndex, list of list of string
llsTableData optional) // Tells presence of a text in the table

List of String GetRowText (TABLEROW Row, boolean bShowSpannedCell optional)

integer GetRowIndex (String sKey, int iSearchColIndex, list of list of string llsTableData optional)



Declaration of Table Object:
=====================
[+] BorderlessTable tblBalanceDetails
        [ ] tag "$balanceDetails"
        [ ] real rLevelOfRecognition = 0.76 // This is a mandatory datamember, tells at which level table is visible.


Usage
========================
    [ ] boolean bFound =Page.tblBorderLess.DoesKeyExists ("abc ", 1) // searches for the presence of text "abc" in the column1 of the table
    [ ] Verify(bFound, true, "Verifying that key exists in the column1")


// no need to explicitly set the borderless table setting before calling the method.

Definition of Functions:
========================

[+] winclass BorderlessTable : HtmlTable
   [ ] // ***************************************************************
   [ ] // Data-Member Section
   [ ] setting DontInheritClassTag = True // Prevent Recorder and GetChildren from Overriding Standard Class with this extended Class
   [ ]
   [ ] real rLevelOfRecognition = null
   [ ] const real rDefaultLevelofrecognition = 0.76

   [+] boolean Exists (number nTimeOut optional)
    [ ] boolean bExists
    [ ] //Reading the option level that is present, end of the function it resets back to this level.
    [ ] real rPreviousLevel = BrowserPage.GetUserOption ('ShowBorderlessTables')
    [ ]
    [+] if rLevelOfRecognition == null
      [ ] //assigning default recognition level
      [ ] rLevelOfRecognition = rDefaultLevelofrecognition
    [+] else
      [ ] //Validating the range.
      [+] if rLevelOfRecognition < 0 || rLevelOfRecognition > 1
        [ ] RaiseError (INVALID_PARAMETER,"Value of parameter 'rLevelOfRecognition' should be in the range of ZERO to ONE")
    [+] do
      [+] if rPreviousLevel != rLevelOfRecognition
        [ ] BrowserPage.SetUserOption ('ShowBorderlessTables', rLevelOfRecognition)

      [ ] bExists = derived :: Exists (nTimeOut)
      [+] if rPreviousLevel != rLevelOfRecognition
        [ ] BrowserPage.SetUserOption ('ShowBorderlessTables', rPreviousLevel)
        [ ]
    [+] except
      [+] if rPreviousLevel != rLevelOfRecognition
        [ ] BrowserPage.SetUserOption ('ShowBorderlessTables', rPreviousLevel)
        [ ]
      [ ] reraise
    [ ] return bExists

  [+] list of list of string GetTableData (boolean bIncludeEmptyCells optional)
        [ ] list of list of string llsData = {}
        [ ] int iRow, iCol
        [ ] list of string lsRowData
        [+] if rLevelOfRecognition == null
              [ ] //assigning default recognition level
              [ ] rLevelOfRecognition = rDefaultLevelofrecognition
        [+] else
              [ ] //Validating the range.
              [+] if rLevelOfRecognition < 0 || rLevelOfRecognition > 1
                    [ ] RaiseError (INVALID_PARAMETER,"Value of parameter 'rLevelOfRecognition' should be in the range of ZERO to ONE")
        [ ] //setting default value of bIncludeEmptyCells as true
        [+] if bIncludeEmptyCells == null
              [ ] bIncludeEmptyCells = true
        [ ] //Reading the option level that is present, end of the function it resets back to this level.
        [ ] real rPreviousLevel = BrowserPage.GetUserOption ('ShowBorderlessTables')
        [+] do
              [+] if rPreviousLevel != rLevelOfRecognition
                    [ ] BrowserPage.SetUserOption('ShowBorderlessTables', rLevelOfRecognition)
              [ ] BrowserPage.SetUserOption("RowTextIncludesEmptyCells", bIncludeEmptyCells)
              [ ] // Checking for the presence of Table
              [+] if !this.Exists()
                    [ ] RaiseError(GENERAL_SCRIPT_ERROR, "Cannot find table object {this}")
              [ ] llsData = this.GetRowRangeText(1)
              [ ]
              [+] if rPreviousLevel != rLevelOfRecognition
                    [ ] BrowserPage.SetUserOption('ShowBorderlessTables', rPreviousLevel)
              [ ] BrowserPage.SetUserOption("RowTextIncludesEmptyCells", false)
        [+] except
              [+] if rPreviousLevel != rLevelOfRecognition
                    [ ]
                    [ ] BrowserPage.SetUserOption('ShowBorderlessTables', rPreviousLevel)
                    [ ]
              [ ] BrowserPage.SetUserOption("RowTextIncludesEmptyCells", false)
              [ ] reraise
              [ ]
        [+] if llsData == {}
              [ ] RaiseError (GENERAL_SCRIPT_ERROR, "Unable to get Table Data.")
        [ ] //Trimming the all cell values in the table.
        [+] for iRow=1 to listcount(llsData)
              [ ] lsRowData=llsData[iRow]
              [ ]
              [+] for iCol=1 to listcount(lsRowData)
                    [ ] llsData[iRow][iCol]=Trim(llsData[iRow][iCol])
        [ ]
        [ ] return llsData

  [ ]Returns presence of Key text in the table.
  [+] boolean DoesKeyExists (String sKey, int iSearchColIndex, list of list of string llsTableData optional)
    [ ]
    [ ] boolean bFound = false
    [ ] int i
    [ ]
    [-] if llsTableData==null
      [ ] llsTableData = this.GetTableData ()
    [ ]
    [-] for i=1 to ListCount (llsTableData)
      [ ]
      [-] if CaseSensitiveMatchString (sKey,llsTableData[i][iSearchColIndex])
        [ ]
        [ ] bFound = true
        [ ] break
    [ ]
    [ ] return bFound


  [+] integer GetRowCount ( )
    [ ] real rPreviousBLTLevel
    [ ] integer iRows = 0
    [ ]
    [-] if rLevelOfRecognition == null
      [ ] //assigning default recognition level
      [ ] rLevelOfRecognition = rDefaultLevelofrecognition
    [ ]
    [ ] rPreviousBLTLevel = BrowserOptions.SetBorderLessTableLevel ( rLevelOfRecognition )
    [-] do
      [ ] iRows = derived :: GetRowCount ()
      [ ] BrowserOptions.SetBorderLessTableLevel ( rPreviousBLTLevel )
    [-] except
      [ ] BrowserOptions.SetBorderLessTableLevel ( rPreviousBLTLevel )
      [ ] reraise
    [ ]
    [-] if iRows == 0
      [ ] RaiseError (GENERAL_SCRIPT_ERROR, "Table is empty")
    [ ] return iRows
  [ ]
  [+] List of String GetRowText (TABLEROW Row, boolean bShowSpannedCell optional)
    [ ]
    [ ] List of STRING lsRowData = {}
    [ ] real rPreviousBLTLevel
    [ ] int iCol
    [ ]
    [+] if rLevelOfRecognition == null
      [ ] //assigning default recognition level
      [ ] rLevelOfRecognition = rDefaultLevelofrecognition
    [ ]
    [ ] rPreviousBLTLevel = BrowserOptions.SetBorderLessTableLevel ( rLevelOfRecognition )
    [+] do
      [ ] lsRowData = derived :: GetRowText (Row, bShowSpannedCell)
      [ ] BrowserOptions.SetBorderLessTableLevel ( rPreviousBLTLevel )
    [+] except
      [ ] BrowserOptions.SetBorderLessTableLevel ( rPreviousBLTLevel )
      [ ] reraise
    [ ]
    [ ] //Trimming all the cell values in the row
    [+] for iCol =1 to listcount(lsRowData)
      [ ] lsRowData[iCol] = Trim ( lsRowData[iCol] )
    [ ]
    [ ] return lsRowData


  [+] integer GetRowIndex (String sKey, int iSearchColIndex, list of list of string llsTableData optional)
    [+] //HELP:
      [ ] // Returns the rowindex of given key, on presence of Key it returns Non-Zero value, [else] zero.
      [ ] // sRowValue can be AccountNumbers/status etc
      [ ] // iSearchColIndex is the table Coloumn index in which it searches for Key.Default Value is 1 i.e the first column
    [ ]
    [ ] integer i, iIndex = 0
    [-] if llsTableData==null
      [ ] llsTableData = this.GetTableData ()
    [-] for i=1 to ListCount (llsTableData)
      [+] if CaseSensitiveMatchString (sKey,llsTableData[i][iSearchColIndex])
        [ ] iIndex = i
        [ ] break
    [-] if iIndex == 0
      [ ]
      [ ] RaiseError (GENERAL_SCRIPT_ERROR, "Unable to find {sKey} in {iSearchColIndex} Column.")
      [ ]
    [ ] return iIndex