Class TableParser
java.lang.Object
dev.botcity.framework.web.parsers.TableParser
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondataFromRow
(org.openqa.selenium.WebElement row, String cellTag, String cellXpath) Extract data from a row and return it as a list.sanitizeHeader
(List<String> labels) Sanitize header labels.tableToMapArray
(org.openqa.selenium.WebElement table) Convert a table WebElement to a list of mapstableToMapArray
(org.openqa.selenium.WebElement table, boolean hasHeader, int skipRows) Convert a table WebElement to a list of mapstableToMapArray
(org.openqa.selenium.WebElement table, boolean hasHeader, int skipRows, String headerTag) Convert a table WebElement to a list of mapstableToMapArray
(org.openqa.selenium.WebElement table, boolean hasHeader, int skipRows, String headerTag, String cellXpath) Convert a table WebElement to a list of maps
-
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
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
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.
-