Package allurium.primitives
Class Button
java.lang.Object
allurium.primitives.UIElement
allurium.inputs.AbstractInputElement
allurium.primitives.Button
- All Implemented Interfaces:
AlluriumElement,InputElement,ListComponent,WebElementMeta
Represents a Button element in the UI, extending
AbstractInputElement.
This class provides additional functionality specific to button elements, such as setting the element type to "button" and offering utility methods for creating button instances. It also includes helper methods to simplify interaction and assertions for button elements in tests.
Features:
- Sets the UI element type as "button" for easier identification.
- Supports convenient factory methods for instantiating button objects.
- Integrates with the
AbstractInputElementfunctionality for input-related behavior.
Purpose:
- Encapsulates button-specific behavior for improved test readability and maintainability.
- Standardizes the creation and management of button elements in UI tests.
Usage Example:
Button button = new Button("button.submit");
button.click();
button.assertEnabled();
-
Field Summary
Fields inherited from class allurium.primitives.UIElement
assignNameMethod, description, id, parent, root, stepsConsoleLoggingEnabled, stepsReportLoggingEnabled, uiElementName, uiElementType -
Constructor Summary
ConstructorsConstructorDescriptionButton()Default constructor.Button(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes a button using a Selenide element.Constructor that initializes a button using a Selenide element and a name.Constructor that initializes a button using a Selenide locator string.Constructor that initializes a button using a Selenide locator string and a name.Button(org.openqa.selenium.By locator) Constructor that initializes a button using a SeleniumBylocator.Constructor that initializes a button using a SeleniumBylocator and a name. -
Method Summary
Modifier and TypeMethodDescriptionstatic ButtonCreates a button using an XPath string.static Button$button(com.codeborne.selenide.SelenideElement selenideElement) Creates a button using a Selenide element.static ButtonCreates a button using a Selenide element and a name.static ButtonCreates a button using a Selenide locator string.static ButtonCreates a button using a Selenide locator string and a name.static ButtonCreates a button using a SeleniumBylocator and a name.getId()Retrieves the unique identifier for this button, which is its text.Methods inherited from class allurium.inputs.AbstractInputElement
assertDisabled, assertEnabled, isDisabledMethods 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, 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
-
Button
public Button()Default constructor. Initializes the button element type. -
Button
Constructor that initializes a button using a Selenide locator string.- Parameters:
selenideLocator- the Selenide locator as a string
-
Button
public Button(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes a button using a Selenide element.- Parameters:
selenideElement- the Selenide element representing the button
-
Button
public Button(org.openqa.selenium.By locator) Constructor that initializes a button using a SeleniumBylocator.- Parameters:
locator- the Selenium locator for the button
-
Button
Constructor that initializes a button using a SeleniumBylocator and a name.- Parameters:
locator- the Selenium locator for the buttonname- the name of the button
-
Button
Constructor that initializes a button using a Selenide element and a name.- Parameters:
selenideElement- the Selenide element representing the buttonname- the name of the button
-
Button
Constructor that initializes a button using a Selenide locator string and a name.- Parameters:
selenideLocator- the Selenide locator as a stringname- the name of the button
-
-
Method Details
-
$button
Creates a button using a SeleniumBylocator and a name.- Parameters:
locator- the Selenium locator for the buttonname- the name of the button- Returns:
- a new
Buttoninstance
-
$button
Creates a button using a Selenide element.- Parameters:
selenideElement- the Selenide element representing the button- Returns:
- a new
Buttoninstance
-
$button
Creates a button using a Selenide element and a name.- Parameters:
selenideElement- the Selenide element representing the buttonname- the name of the button- Returns:
- a new
Buttoninstance
-
$button
Creates a button using a Selenide locator string.- Parameters:
selenideLocator- the Selenide locator as a string- Returns:
- a new
Buttoninstance
-
$button
Creates a button using a Selenide locator string and a name.- Parameters:
selenideLocator- the Selenide locator as a stringname- the name of the button- Returns:
- a new
Buttoninstance
-
_$button
Creates a button using an XPath string.- Parameters:
xpath- the XPath string for the button- Returns:
- a new
Buttoninstance
-
getId
Retrieves the unique identifier for this button, which is its text.- Specified by:
getIdin interfaceListComponent- Overrides:
getIdin classUIElement- Returns:
- the button's text as its unique identifier
-