Class GridElement

  • All Implemented Interfaces:
    com.vaadin.testbench.commands.CanCompareScreenshots, com.vaadin.testbench.commands.CanWaitForVaadin, com.vaadin.testbench.commands.TestBenchElementCommands, com.vaadin.testbench.HasDriver, com.vaadin.testbench.HasSearchContext, com.vaadin.testbench.HasTestBenchCommandExecutor, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WebElement, org.openqa.selenium.WrapsElement
    Direct Known Subclasses:
    TreeGridElement

    public class GridElement
    extends AbstractComponentElement
    TestBench Element API for Grid.
    Author:
    Vaadin Ltd
    • Constructor Detail

      • GridElement

        public GridElement()
    • Method Detail

      • scrollToRow

        public void scrollToRow​(int index)
        Scrolls Grid element so that wanted row is displayed.
        Parameters:
        index - Target row
      • getCell

        public GridElement.GridCellElement getCell​(int rowIndex,
                                                   int colIndex)
        Gets cell element with given row and column index.
        Parameters:
        rowIndex - Row index
        colIndex - Column index
        Returns:
        Cell element with given indices.
      • getRow

        public GridElement.GridRowElement getRow​(int index)
        Gets row element with given row index.
        Parameters:
        index - Row index
        Returns:
        Row element with given index.
      • getHeaderCell

        public GridElement.GridCellElement getHeaderCell​(int rowIndex,
                                                         int colIndex)
        Gets header cell element with given row and column index.
        Parameters:
        rowIndex - Row index
        colIndex - Column index
        Returns:
        Header cell element with given indices.
      • getHeaderCellByCaption

        public GridElement.GridCellElement getHeaderCellByCaption​(String caption)
        Finds the header cell element with the given caption. If there are multiple headers with the same name, the first one is returned.
        Parameters:
        caption - The header caption
        Returns:
        The first header cell element with a given caption.
        Throws:
        org.openqa.selenium.NoSuchElementException - if there is no header row or no header cell with the given text.
      • getHeaderCellByCaption

        public GridElement.GridCellElement getHeaderCellByCaption​(int rowIndex,
                                                                  String caption)
        Gets the header cell element with the given caption in the given header row. If there are multiple headers with the same name, the first one is returned.
        Parameters:
        rowIndex - The index of the header row
        caption - The header caption
        Returns:
        The first header cell element with a given caption.
        Throws:
        org.openqa.selenium.NoSuchElementException - if there is no header row or no header cell with the given text.
      • getFooterCell

        public GridElement.GridCellElement getFooterCell​(int rowIndex,
                                                         int colIndex)
        Gets footer cell element with given row and column index.
        Parameters:
        rowIndex - Row index
        colIndex - Column index
        Returns:
        Footer cell element with given indices.
      • getHeaderCells

        public List<GridElement.GridCellElement> getHeaderCells​(int rowIndex)
        Gets list of header cell elements on given row.
        Parameters:
        rowIndex - Row index
        Returns:
        Header cell elements on given row.
      • getFooterCells

        public List<GridElement.GridCellElement> getFooterCells​(int rowIndex)
        Gets list of header cell elements on given row.
        Parameters:
        rowIndex - Row index
        Returns:
        Header cell elements on given row.
      • getHeaderCount

        public int getHeaderCount()
        Get header row count.
        Returns:
        Header row count
      • getFooterCount

        public int getFooterCount()
        Get footer row count.
        Returns:
        Footer row count
      • getHeaderRow

        public com.vaadin.testbench.TestBenchElement getHeaderRow​(int rowIndex)
        Get a header row by index.
        Parameters:
        rowIndex - Row index
        Returns:
        The th element of the row
      • getFooterRow

        public com.vaadin.testbench.TestBenchElement getFooterRow​(int rowIndex)
        Get a footer row by index.
        Parameters:
        rowIndex - Row index
        Returns:
        The tr element of the row
      • getVerticalScroller

        public com.vaadin.testbench.TestBenchElement getVerticalScroller()
        Get the vertical scroll element.
        Returns:
        The element representing the vertical scrollbar
      • getHorizontalScroller

        public com.vaadin.testbench.TestBenchElement getHorizontalScroller()
        Get the horizontal scroll element.
        Returns:
        The element representing the horizontal scrollbar
      • getHeader

        public com.vaadin.testbench.TestBenchElement getHeader()
        Get the header element.
        Returns:
        The thead element
      • getBody

        public com.vaadin.testbench.TestBenchElement getBody()
        Get the body element.
        Returns:
        the tbody element
      • getFooter

        public com.vaadin.testbench.TestBenchElement getFooter()
        Get the footer element.
        Returns:
        the tfoot element
      • getTableWrapper

        public com.vaadin.testbench.TestBenchElement getTableWrapper()
        Get the element wrapping the table element.
        Returns:
        The element that wraps the table element
      • getDetails

        public com.vaadin.testbench.TestBenchElement getDetails​(int rowIndex)
                                                         throws org.openqa.selenium.NoSuchElementException
        Gets the element that contains the details of a row.
        Parameters:
        rowIndex - the index of the row for the details
        Returns:
        the element that contains the details of a row. null if no widget is defined for the details row
        Throws:
        org.openqa.selenium.NoSuchElementException - if the given details row is currently not open
        Since:
        8.0
      • toggleColumnHidden

        public void toggleColumnHidden​(String toggleCaption)
        Toggles the column visibility. Column is identified by its hiding toggle caption.
        Parameters:
        toggleCaption -
        Since:
        8.0.6
      • getRowCount

        public long getRowCount()
        Gets the total number of data rows in the grid.
        Returns:
        the number of data rows in the grid,
      • getRows

        public Iterable<GridElement.GridRowElement> getRows()
        Gets all the data rows in the grid.

        Returns an iterable which will lazily scroll rows into views and lazy load data as needed.

        Returns:
        an iterable of all the data rows in the grid.