Class JSDropdownElement

Direct Known Subclasses:
MaterialUISelect, PrimeNGDropdown

public abstract class JSDropdownElement extends Dropdown
A number of angular and react libraries make their own dropdowns that are do not use select elements. This class creates a base for implementing various javascript dropdowns so that they can be treated as normal selenium dropdowns.
NOTE: This extends Dropdown and not PageSelectElement because there are plans to have the dropdown type auto-detected in a later version.
  • Constructor Details

    • JSDropdownElement

      protected JSDropdownElement(String elementName, Map<String,String> selectors)
      /** Implementation of a Dropdown to initialize how an element is going to be found when it is worked on by the WebDriver class. Takes a reference to the WebDriver class that will be exercising its functionality.
      Parameters:
      elementName - String the name of the element
      selectors - Map<String,String> the list of selectors to use to find the element
  • Method Details

    • getOption

      protected abstract org.openqa.selenium.WebElement getOption(String selectionText)
      Returns a WebElement for an option with the given text.
      Parameters:
      selectionText - String the text to be selected
      Returns:
      WebElement the element representing the option
    • getOption

      protected abstract org.openqa.selenium.WebElement getOption(int index)
      Returns a WebElement for an option with the given index.
      Parameters:
      index - int the index of the option, starting with 1
      Returns:
      WebElement the element representing the option
    • select

      public SelectElement select(String selectionText)
      Selects an option from a drop down using the text value of the item to select.
      Overrides:
      select in class SelectElement
      Parameters:
      selectionText - the value to select
      Returns:
      PageSelectElement for object chaining
    • select

      public SelectElement select(int index)
      Selects an option from a drop down using the ordinal value of the item to select.
      Overrides:
      select in class SelectElement
      Parameters:
      index - the index to select
      Returns:
      PageSelectElement for object chaining
    • getText

      public String getText(int index)
      Gets the value of the item at the given index.
      Overrides:
      getText in class SelectElement
      Parameters:
      index - the index to inspect, starting with 1
      Returns:
      String the text value of the option at the given index
    • getText

      public String getText()
      Gets the text of the first item currently selected.
      Overrides:
      getText in class SelectElement
      Returns:
      String the text value of the selected option