Class JSDropdownElement
java.lang.Object
com.dougnoel.sentinel.elements.Element
com.dougnoel.sentinel.elements.dropdowns.SelectElement
com.dougnoel.sentinel.elements.dropdowns.Dropdown
com.dougnoel.sentinel.elements.dropdowns.JSDropdownElement
- Direct Known Subclasses:
MaterialUISelect
,PrimeNGDropdown
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.
NOTE: This extends Dropdown and not PageSelectElement because there are plans to have the dropdown type auto-detected in a later version.
-
Field Summary
Fields inherited from class com.dougnoel.sentinel.elements.Element
elementType, log, name, selectors
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
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. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract org.openqa.selenium.WebElement
getOption
(int index) Returns a WebElement for an option with the given index.protected abstract org.openqa.selenium.WebElement
Returns a WebElement for an option with the given text.getText()
Gets the text of the first item currently selected.getText
(int index) Gets the value of the item at the given index.select
(int index) Selects an option from a drop down using the ordinal value of the item to select.Selects an option from a drop down using the text value of the item to select.Methods inherited from class com.dougnoel.sentinel.elements.dropdowns.SelectElement
doesNotHaveOption, getNumberOfOptions, hasOption, select
Methods inherited from class com.dougnoel.sentinel.elements.Element
attributeContains, attributeEquals, classContains, clear, click, clickPositionOnChildElement, clickPositionOnElement, contextClick, createByLocator, doesNotExist, doesNotHaveAttribute, dragAndDrop, element, element, existsAtThisInstant, findElementInCurrentFrame, findElementInIFrame, getAttribute, getBackgroundColor, getBy, getLocation, getMostPrevalentColor, getName, getScreenshot, getTooltipText, hasAttribute, hover, isDisabled, isDisplayed, isEnabled, isHidden, isNotSelected, isSelected, sendFilePaths, sendKeys, sendSpecialKey, waitForText
-
Constructor Details
-
JSDropdownElement
/** 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 elementselectors
- Map<String,String> the list of selectors to use to find the element
-
-
Method Details
-
getOption
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
Selects an option from a drop down using the text value of the item to select.- Overrides:
select
in classSelectElement
- Parameters:
selectionText
- the value to select- Returns:
- PageSelectElement for object chaining
-
select
Selects an option from a drop down using the ordinal value of the item to select.- Overrides:
select
in classSelectElement
- Parameters:
index
- the index to select- Returns:
- PageSelectElement for object chaining
-
getText
Gets the value of the item at the given index.- Overrides:
getText
in classSelectElement
- Parameters:
index
- the index to inspect, starting with 1- Returns:
- String the text value of the option at the given index
-
getText
Gets the text of the first item currently selected.- Overrides:
getText
in classSelectElement
- Returns:
- String the text value of the selected option
-