Class TableParser

java.lang.Object
dev.botcity.framework.web.parsers.TableParser

public class TableParser extends Object
  • Constructor Details

    • TableParser

      public TableParser()
  • Method Details

    • dataFromRow

      public static List<String> dataFromRow(org.openqa.selenium.WebElement row, String cellTag, String cellXpath)
      Extract data from a row and return it as a list.
      Parameters:
      row - The row element.
      cellTag - The HTML tag associated with the row cells.
      cellXpath - The XPath expression associated with the row cels. Defaults to null. If informed, overwrites the `cellTag` definition.
      Returns:
      List of strings with the contents.
    • sanitizeHeader

      public static List<String> sanitizeHeader(List<String> labels)
      Sanitize header labels.
      Parameters:
      labels - The labels to format.
      Returns:
      The List with the formatted labels.
    • tableToMapArray

      public static List<Map<String,String>> tableToMapArray(org.openqa.selenium.WebElement table, boolean hasHeader, int skipRows, String headerTag, String cellXpath)
      Convert a table WebElement to a list of maps
      Parameters:
      table - The table element.
      hasHeader - Whether or not to parse a header. Defaults to true.
      skipRows - Number of rows to skip from the top. Defaults to 0.
      headerTag - The HTML tag associated with the header cell. Defaults to "th".
      cellXpath - Optional cell XPath selector for complex row constructions. If `cellXpath` is not informed, the row data will come from "td" elements.
      Returns:
      The List with a Map for each table row.
    • tableToMapArray

      public static List<Map<String,String>> tableToMapArray(org.openqa.selenium.WebElement table)
      Convert a table WebElement to a list of maps
      Parameters:
      table - The table element.
      Returns:
      The List with a Map for each table row.
    • tableToMapArray

      public static List<Map<String,String>> tableToMapArray(org.openqa.selenium.WebElement table, boolean hasHeader, int skipRows)
      Convert a table WebElement to a list of maps
      Parameters:
      table - The table element.
      hasHeader - Whether or not to parse a header. Defaults to true.
      skipRows - Number of rows to skip from the top. Defaults to 0.
      Returns:
      The List with a Map for each table row.
    • tableToMapArray

      public static List<Map<String,String>> tableToMapArray(org.openqa.selenium.WebElement table, boolean hasHeader, int skipRows, String headerTag)
      Convert a table WebElement to a list of maps
      Parameters:
      table - The table element.
      hasHeader - Whether or not to parse a header. Defaults to true.
      skipRows - Number of rows to skip from the top. Defaults to 0.
      headerTag - The HTML tag associated with the header cell. Defaults to "th".
      Returns:
      The List with a Map for each table row.