Class AbstractSwitcher
- All Implemented Interfaces:
AlluriumElement,ListComponent,WebElementMeta
UIElement.
This abstract class provides a foundation for creating toggleable components such as switches, checkboxes, or other binary-state elements. It defines methods to query the current state and perform toggle or state-changing actions, while delegating specific behavior to subclasses.
Features:
- Encapsulates common behaviors of switcher components.
- Standardizes the interface for querying and modifying switcher states.
- Supports Allure step logging for state-change actions.
Purpose:
- Encourages consistent implementation of switcher-like components across the codebase.
- Provides a reusable base for custom UI switcher elements.
Constructors:
AbstractSwitcher()- Default constructor.AbstractSwitcher(String)- Initializes a switcher using a Selenide locator string.AbstractSwitcher(String, String)- Initializes a switcher using a Selenide locator string and a name.AbstractSwitcher(By)- Initializes a switcher using a SeleniumBylocator.AbstractSwitcher(By, String)- Initializes a switcher using a SeleniumBylocator and a name.AbstractSwitcher(SelenideElement)- Initializes a switcher using a Selenide element.AbstractSwitcher(SelenideElement, String)- Initializes a switcher using a Selenide element and a name.
Example Implementation:
public class ButtonToggle extends AbstractSwitcher {
public ButtonToggle(String selenideLocator) {
super(selenideLocator);
}-
Field Summary
Fields inherited from class allurium.primitives.UIElement
assignNameMethod, description, id, parent, root, stepsConsoleLoggingEnabled, stepsReportLoggingEnabled, uiElementName, uiElementType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor.AbstractSwitcher(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes a switcher using a Selenide element.protectedAbstractSwitcher(com.codeborne.selenide.SelenideElement selenideElement, String name) Constructor that initializes a switcher using a Selenide element and a name.protectedAbstractSwitcher(String selenideLocator) Constructor that initializes a switcher using a Selenide locator string.protectedAbstractSwitcher(String selenideLocator, String name) Constructor that initializes a switcher using a Selenide locator string and a name.protectedAbstractSwitcher(org.openqa.selenium.By locator) Constructor that initializes a switcher using a SeleniumBylocator.protectedAbstractSwitcher(org.openqa.selenium.By locator, String name) Constructor that initializes a switcher using a SeleniumBylocator and a name. -
Method Summary
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, setAssignNameMethod, setDescription, setParent, setUiElementName
-
Constructor Details
-
AbstractSwitcher
protected AbstractSwitcher()Default constructor. Initializes the element type as "switcher". -
AbstractSwitcher
Constructor that initializes a switcher using a Selenide locator string.- Parameters:
selenideLocator- the Selenide locator as a string
-
AbstractSwitcher
Constructor that initializes a switcher using a Selenide locator string and a name.- Parameters:
selenideLocator- the Selenide locator as a stringname- the name of the switcher
-
AbstractSwitcher
protected AbstractSwitcher(org.openqa.selenium.By locator) Constructor that initializes a switcher using a SeleniumBylocator.- Parameters:
locator- the Selenium locator for the switcher
-
AbstractSwitcher
Constructor that initializes a switcher using a SeleniumBylocator and a name.- Parameters:
locator- the Selenium locator for the switchername- the name of the switcher
-
AbstractSwitcher
public AbstractSwitcher(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes a switcher using a Selenide element.- Parameters:
selenideElement- the Selenide element representing the switcher
-
AbstractSwitcher
Constructor that initializes a switcher using a Selenide element and a name.- Parameters:
selenideElement- the Selenide element representing the switchername- the name of the switcher
-
-
Method Details
-
getState
public abstract boolean getState()Retrieves the current state of the switcher.Subclasses should implement this method to return whether the switcher is ON or OFF.
- Returns:
trueif the switcher is ON;falseotherwise
-
toggle
public abstract void toggle()Toggles the current state of the switcher.This method changes the state of the switcher from ON to OFF or vice versa. It should be implemented in subclasses.
Step: Processed by Aspect
-
switchOn
public abstract void switchOn()Sets the switcher state to ON.If the switcher is already ON, this method does nothing. Otherwise, it performs the necessary actions to turn the switcher ON.
Step: Processed by Aspect
-
switchOff
public abstract void switchOff()Sets the switcher state to OFF.If the switcher is already OFF, this method does nothing. Otherwise, it performs the necessary actions to turn the switcher OFF.
Step: Processed by Aspect
-