Class TreeElement

  • 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

    public class TreeElement
    extends AbstractComponentElement
    Testbench Element API for Tree.

    Note: This TreeElement is for the Vaadin 8 version of Tree. Use TreeElement for the compatibility version.

    Since:
    8.1
    Author:
    Vaadin Ltd.
    • Constructor Summary

      Constructors 
      Constructor Description
      TreeElement()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected TreeGridElement asTreeGrid()
      Convenience method for accessing the underlying TreeGrid.
      void collapse​(int index)
      Collapses the row at the given index in the tree.
      void expand​(int index)
      Expands the row at the given index in the tree.
      protected com.vaadin.testbench.TestBenchElement findCellContentFromRow​(org.openqa.selenium.WebElement rowElement)
      Finds the rendered cell content from given row element.
      List<com.vaadin.testbench.TestBenchElement> getAllItems()
      Gets all items currently shown in this tree.
      org.openqa.selenium.WebElement getExpandElement​(int rowIndex)
      Gets the expand/collapse element for the given row.
      com.vaadin.testbench.TestBenchElement getItem​(int index)
      Gets an item at given index.
      boolean isCollapsed​(int rowIndex)
      Returns whether the row at the given index is collapsed or not.
      boolean isExpanded​(int index)
      Returns whether the row at the given index is expanded or not.
      • Methods inherited from class com.vaadin.testbench.TestBenchElement

        clear, click, click, clickHiddenElement, compareScreen, compareScreen, compareScreen, contextClick, doubleClick, equals, findElement, findElements, focus, getAccessibleName, getAriaRole, getAttribute, getCapabilities, getClassNames, getCommandExecutor, getContext, getCssValue, getDomAttribute, getDriver, getId, getLocation, getRect, getScreenshotAs, getShadowRoot, getSize, getTagName, getText, getWrappedElement, hasAttribute, hasClassName, hashCode, init, init, isChrome, isDisplayed, isEnabled, isFirefox, isFocused, isSelected, scroll, scrollIntoView, scrollLeft, sendKeys, showTooltip, submit, waitForVaadin, waitUntil, waitUntil, wrap, wrapElement, wrapElements
      • Methods inherited from class com.vaadin.testbench.AbstractHasTestBenchCommandExecutor

        $, $$, isElementPresent, isElementPresent
      • Methods inherited from interface org.openqa.selenium.WebElement

        getDomProperty
    • Constructor Detail

      • TreeElement

        public TreeElement()
    • Method Detail

      • expand

        public void expand​(int index)
        Expands the row at the given index in the tree.
        Parameters:
        index - 0-based row index to expand
      • isExpanded

        public boolean isExpanded​(int index)
        Returns whether the row at the given index is expanded or not.
        Parameters:
        index - 0-based row index
        Returns:
        true if expanded, false if collapsed
      • isCollapsed

        public boolean isCollapsed​(int rowIndex)
        Returns whether the row at the given index is collapsed or not.
        Parameters:
        rowIndex - 0-based row index
        Returns:
        true if collapsed, false if expanded
      • getExpandElement

        public org.openqa.selenium.WebElement getExpandElement​(int rowIndex)
        Gets the expand/collapse element for the given row.
        Parameters:
        rowIndex - 0-based row index
        Returns:
        the span element that is clicked for expanding/collapsing a row
        Throws:
        org.openqa.selenium.NoSuchElementException - if there is no expand element for this row
      • collapse

        public void collapse​(int index)
        Collapses the row at the given index in the tree.
        Parameters:
        index - 0-based row index to collapse
      • getAllItems

        public List<com.vaadin.testbench.TestBenchElement> getAllItems()
        Gets all items currently shown in this tree. The returned element objects are the rendered contents for each item.
        Returns:
        list of content elements for all items
      • getItem

        public com.vaadin.testbench.TestBenchElement getItem​(int index)
        Gets an item at given index. The returned element object is the rendered content in the given index.
        Parameters:
        index - 0-based row index
        Returns:
        content element for item at given index
      • findCellContentFromRow

        protected com.vaadin.testbench.TestBenchElement findCellContentFromRow​(org.openqa.selenium.WebElement rowElement)
        Finds the rendered cell content from given row element. This expects the row to contain only a single column rendered with TreeRenderer.
        Parameters:
        rowElement - the row element
        Returns:
        cell content element
      • asTreeGrid

        protected TreeGridElement asTreeGrid()
        Convenience method for accessing the underlying TreeGrid.
        Returns:
        this tree element as a tree grid element.