All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.magentys.cinnamon.webdriver.elements.Table Maven / Gradle / Ivy

package io.magentys.cinnamon.webdriver.elements;

import java.util.List;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;

public interface Table {

    /**
     * Adapter to convert a row into the specified type.
     * 
     * @param  The type this adapter returns
     */
    interface RowAdapter {
        AdaptedResult adapt(List columnHeaders, List cells);
    }

    /**
     * Convert the rows of this table into a list of the given type. Converts the column headings of the table into
     * field names. Reflection is used to set the properties perform the class - setters are not required.
     * 
     * The column heading is converted to a field name using the following rules: - fields are changed to camel case,
     * using spaces/illegal characters to identify capitalisation - spaces are removed - illegal characters are removed
     * ('/')
     * 
     * Examples
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
     * 
*
column headingfield name
Foo bar bazfooBarBaz
foobarbazfoobarbaz
Foo/BarfooBar
* * Any column headings that do not correspond to a field in the given type are ignored. * * @param type The type representing the rows of the list. Must have a public no-argument constructor. * @return */ List asList(Class type); /** * Adapt the rows of this table into a list of items using the given type adapter * * The adapter shall be called with the list of column headers elements. The number of elements in the * columnHeaders list shall equal the number of cell elements. * * Example - for the following table: * * * * * * * * * * * * * * * * * * * * *
ab
12
34
56
* *
     * adapt shall be called 3 times with the equivalent of:
     * adapt([a,b],[12])
     * adapt([a,b],[34])
     * adapt([a,b],[56])
     * 
* */ List asList(RowAdapter adapter); /** * Convert this pivot table into a list of cells using the given adapter. It will iterate through each row in the * table, adapting all the cells (apart from the first cell, which is considered the row heading) * * @param adapter An adapter that will convert the cells to the required type * @return */ List asPivot(TableElement.CellAdapter adapter); List asPivot(TableElement.MultiCellAdapter adapter); /** * Set the number of column headers to ignore for each rowHeader when using pivot tables. * * @param n * @return */ Table withRowHeaderColspan(int n); /** * Find the first cell (columnHeader,rowHeader,intersecting cell) that matches the given matcher, such that * {@link TableElement.CellAdapter#adapt(org.openqa.selenium.WebElement, org.openqa.selenium.WebElement, org.openqa.selenium.WebElement)} * returns true. * * If the table contains multiple headers for a column (including spanning), then each cell shall be called in turn * with each of the column headers. So, a table with i rows, j columns, and l column * headers for each row; the matcher shall be called a maximum of j * k * l times. The matcher shall be * called for column headers in the order that they are located (with the top-most column header invoked first). * Note, that in this case, the MatchingCell will contain the first column header which matched. * * @throws NoSuchElementException if no cell matching the parameters is found */ TableElement.MatchingCell firstMatch(TableElement.CellAdapter matcher) throws NoSuchElementException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy