Class SelectElement

java.lang.Object
com.vaadin.testbench.TestBenchElement
com.vaadin.flow.component.select.testbench.SelectElement
All Implemented Interfaces:
CanCompareScreenshots, HasCallFunction, HasDriver, HasElementQuery, HasHelper, HasLabel, HasPlaceholder, HasPropertySettersGetters, HasSearchContext, HasSelectByText, HasTestBenchCommandExecutor, HasValidation, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WebElement, org.openqa.selenium.WrapsElement

public class SelectElement extends TestBenchElement implements HasSelectByText, HasLabel, HasPlaceholder, HasHelper, HasValidation
Testbench Element API for vaadin-select.
  • Constructor Details

    • SelectElement

      public SelectElement()
  • Method Details

    • openPopup

      public void openPopup()
      Opens the popup with options, if it is not already open.
    • closePopup

      public void closePopup()
      Closes the popup with options, if it is open.
    • isOpened

      public boolean isOpened()
      Checks whether the popup with options is open.
      Returns:
      true if the popup is open, false otherwise
    • selectItemByIndex

      public void selectItemByIndex(int index)
      Selects the item with the given index by clicking it in the popup. Opens the popup if it is not open. Clicking the item closes the popup.
      Parameters:
      index - the index of the item to select
    • getItemsStream

      public Stream<SelectElement.ItemElement> getItemsStream()
      Gets the items in the popup as a stream.
      Returns:
      a stream of the items in the popup
    • getItems

      public List<SelectElement.ItemElement> getItems()
      Gets the items in the popup.
      Returns:
      the items in the popup
    • selectByText

      public void selectByText(String text)
      Selects the item with the given text by clicking it in the popup. Opens the popup if it is not open. Clicking the item closes the popup.
      Specified by:
      selectByText in interface HasSelectByText
      Parameters:
      text - the text of the item to select
      Throws:
      NoSuchElementException - if no item has the given text
    • getSelectedText

      public String getSelectedText()
      Description copied from interface: HasSelectByText
      Gets the text of the currently selected option.
      Specified by:
      getSelectedText in interface HasSelectByText
      Returns:
      the text of the current option
    • getSelectedOptionItem

      public SelectElement.ItemElement getSelectedOptionItem()
      Gets the selected item in the popup.
      Returns:
      the selected item in the popup
      Throws:
      NoSuchElementException - if no item is selected
    • getSelectedItem

      public SelectElement.ItemElement getSelectedItem()
      Gets the currently selected item shown in the value button, or null if nothing is selected.
      Returns:
      the selected item, or null if nothing is selected