Class Select
- All Implemented Interfaces:
AlluriumElement,ListComponent,Selectable,WebElementMeta
- Direct Known Subclasses:
DropdownSelect
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.codeborne.selenide.ElementsCollectionCollection of options within the options list.Fields inherited from class allurium.primitives.UIElement
assignNameMethod, description, id, parent, root, stepsConsoleLoggingEnabled, stepsReportLoggingEnabled, uiElementName, uiElementType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSelect()Default constructor.Select(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes the select using a Selenide element.Constructor that initializes the select using a Selenide locator string.Select(org.openqa.selenium.By rootLocator) Constructor that initializes the select using a SeleniumBylocator. -
Method Summary
Modifier and TypeMethodDescriptionstatic Selectstatic Select$select(com.codeborne.selenide.SelenideElement selenideElement) static Selectstatic Select$select(org.openqa.selenium.By locator) voidassertCurrentValue(String value) Asserts that the currently selected value in the select or dropdown list matches the expected value.voidassertCurrentValueIsNot(String value) Asserts that the currently selected value in the select or dropdown list does not match the given value.voidassertHasItem(String item) Asserts that the select or dropdown list contains a specific option by its visible text.voidassertHasItems(List<String> items) method is overridableprotected voidRefreshes the list of options within the options list.voidselect(int index) Selects an option by its index.voidselect(int index, SelectOptions selectOptions) Selects an option by its index with additional selection behavior.voidSelects an option by its visible text.voidselect(String option, SelectOptions selectOptions) Selects an option by its visible text with additional selection behavior.voidSelects a random option from the selectOptionsList.voidselectAnyBesides(String value) Selects any option from the select or dropdown list except the one specified by its value.voidSelects an option by navigating using keyboard arrows.voidSelects the first available option.voidSelects the last available option.Methods inherited from class allurium.primitives.UIElement
_$uiElement, $uiElement, $uiElement, $uiElement, $uiElement, $uiElement, $uiElement, applyName, applyName, as, assertEmpty, assertEquals, assertExists, assertExists, assertHasCssClass, assertHasCssClass, assertHasNotCssClass, assertHasNotCssClass, assertHasNotCssClass, assertHasText, assertIsNotEmpty, assertNotExist, assertNotExist, assertNotVisible, assertNotVisible, assertNotVisible, assertText, assertVisible, assertVisible, assertVisible, assertVisible, assertVisibleInViewport, click, click, click, click, click, clickAndHold, clickAndHold, clickAndHold, contextClick, contextClick, contextClick, doubleClick, doubleClick, doubleClick, get, getAllureCompiledStep, getAttribute, getHeight, getId, getStepText, getUiElementName, getWidth, hover, hover, hover, isDisplayed, logStep, logStepToReport, logStepToReport, scrollTo, scrollTo, scrollTo, setRoot, setRoot, text, verifyEmpty, verifyIsNotEmpty, wrappedNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface allurium.interfaces.AlluriumElement
getRootMethods inherited from interface allurium.interfaces.WebElementMeta
getDescription, getMetaKeys, getParent, getUiElementName, setAssignNameMethod, setDescription, setParent, setUiElementName
-
Field Details
-
options
protected com.codeborne.selenide.ElementsCollection optionsCollection of options within the options list.
-
-
Constructor Details
-
Select
protected Select()Default constructor. Initializes the element type as "select". -
Select
public Select(org.openqa.selenium.By rootLocator) Constructor that initializes the select using a SeleniumBylocator.- Parameters:
rootLocator- the Selenium locator for the dropdown
-
Select
Constructor that initializes the select using a Selenide locator string.- Parameters:
selenideLocator- the Selenide locator as a string
-
Select
public Select(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes the select using a Selenide element.- Parameters:
selenideElement- the Selenide element representing the dropdown
-
-
Method Details
-
$select
-
$select
-
$select
-
_$select
-
refreshOptions
protected void refreshOptions()Refreshes the list of options within the options list. -
select
Selects an option by its visible text.Step: Processed by Aspect
- Specified by:
selectin interfaceSelectable- Parameters:
option- the text of the option to select
-
select
Selects an option by its visible text with additional selection behavior.- Parameters:
option- the text of the option to selectselectOptions- additional selection behavior
-
select
public void select(int index) Selects an option by its index.Step: Processed by Aspect
- Parameters:
index- the index of the option to select
-
select
Selects an option by its index with additional selection behavior.- Parameters:
index- the index of the option to selectselectOptions- additional selection behavior
-
selectByArrowsLeftAndRight
Selects an option by navigating using keyboard arrows.Step: Processed by Aspect
- Parameters:
text- the text of the option to select
-
selectFirst
public void selectFirst()Selects the first available option.Step: Processed by Aspect
- Specified by:
selectFirstin interfaceSelectable
-
selectLast
public void selectLast()Selects the last available option.Step: Processed by Aspect
- Specified by:
selectLastin interfaceSelectable
-
selectAny
public void selectAny()Selects a random option from the selectOptionsList.Step: Processed by Aspect
- Specified by:
selectAnyin interfaceSelectable
-
selectAnyBesides
Selects any option from the select or dropdown list except the one specified by its value.This method filters the dropdown options to exclude the specified value and then selects the first available option that does not match.
Step: Processed by Aspect
- Specified by:
selectAnyBesidesin interfaceSelectable- Parameters:
value- the text of the option to exclude- Throws:
IllegalArgumentException- if no option besides the specified value exists
-
assertCurrentValue
Asserts that the currently selected value in the select or dropdown list matches the expected value.This method verifies the `value` attribute of the select element and ensures it matches the provided input.
Step: Processed by Aspect
Example Usage:
Select selectOptionsList = new Select("select"); selectOptionsList.assertSelectedValue("Expected Option");Behavior:
- Throws an
AssertionErrorif the selected value does not match the provided value.
- Parameters:
value- the expected value to match
- Throws an
-
assertCurrentValueIsNot
Asserts that the currently selected value in the select or dropdown list does not match the given value.This method verifies the `value` attribute of the select element and ensures it is not equal to the provided input.
Step: Processed by Aspect
Example Usage:
Select selectOptionsList = new Select("select"); selectOptionsList.assertSelectedValueIsNot("Excluded Option");Behavior:
- Throws an
AssertionErrorif the selected value matches the provided value.
- Parameters:
value- the value to ensure is not selected
- Throws an
-
assertHasItem
Asserts that the select or dropdown list contains a specific option by its visible text.This method checks the list of available options within the dropdown and verifies that the specified item exists.
Step: Processed by Aspect
Example Usage:
Select selectOptionsList = new Select("select"); selectOptionsList.assertHasItem("Option 1");Behavior:
- Throws an
AssertionErrorif the specified item is not found in the selectOptionsList.
- Parameters:
item- the visible text of the option to verify
- Throws an
-
assertHasItems
method is overridableStep: Processed by Aspect
- Parameters:
items-- Throws:
Throwable
-