Package allurium.primitives
Class Text
java.lang.Object
allurium.primitives.UIElement
allurium.primitives.Text
- All Implemented Interfaces:
AlluriumElement,ListComponent,WebElementMeta
Represents a `Text` element in the UI, extending
UIElement.
This class encapsulates the behavior and attributes of a text-based UI component, such as paragraphs, labels, or any element containing textual content.
Features:
- Encapsulates behavior and attributes of a `Text` element.
- Provides multiple constructors for flexible initialization using:
- Selenide locators as strings
- Selenium
Bylocators SelenideElementinstances
- Includes static factory methods for convenient creation of `Text` instances.
- Overrides `toString` and `getId` methods to return the element's name.
Purpose:
- Standardizes interaction with text elements in the UI.
- Simplifies the creation and validation of text-based elements in tests.
Constructors:
Text()- Default constructor.Text(String)- Creates a `Text` using a Selenide locator string.Text(String, String)- Creates a `Text` using a Selenide locator string and a name.Text(By)- Creates a `Text` using a SeleniumBylocator.Text(By, String)- Creates a `Text` using a SeleniumBylocator and a name.Text(SelenideElement)- Creates a `Text` using aSelenideElement.Text(SelenideElement, String)- Creates a `Text` using aSelenideElementand a name.
Static Factory Methods:
$text(By)- Creates a `Text` using a SeleniumBylocator.$text(By, String)- Creates a `Text` using a SeleniumBylocator and a name.$text(SelenideElement)- Creates a `Text` using aSelenideElement.$text(SelenideElement, String)- Creates a `Text` using aSelenideElementand a name.$text(String)- Creates a `Text` using a Selenide locator string.$text(String, String)- Creates a `Text` using a Selenide locator string and a name._$text(String)- Creates a `Text` using an XPath expression.
Usage Example:
// Creating a text element using a Selenide locator
Text textElement = $text(".text-class");
// Creating a text element with a custom name
Text namedText = $text(By.cssSelector(".text-class"), "Description");
// Getting the text element's name or ID
String textName = namedText.getId();
-
Field Summary
Fields inherited from class allurium.primitives.UIElement
assignNameMethod, description, id, parent, root, stepsConsoleLoggingEnabled, stepsReportLoggingEnabled, uiElementName, uiElementType -
Constructor Summary
ConstructorsConstructorDescriptionText()Default constructor.Text(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes a `Text` element using aSelenideElement.Constructor that initializes a `Text` element using aSelenideElementand a name.Constructor that initializes a `Text` element using a Selenide locator string.Constructor that initializes a `Text` element using a Selenide locator string and a name.Text(org.openqa.selenium.By locator) Constructor that initializes a `Text` element using a SeleniumBylocator.Constructor that initializes a `Text` element 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, 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, 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
-
Text
public Text()Default constructor. Initializes the element type as "text". -
Text
Constructor that initializes a `Text` element using a Selenide locator string.- Parameters:
selenideLocator- the Selenide locator as a string
-
Text
Constructor that initializes a `Text` element using a Selenide locator string and a name.- Parameters:
selenideLocator- the Selenide locator as a stringname- the name of the text element
-
Text
public Text(org.openqa.selenium.By locator) Constructor that initializes a `Text` element using a SeleniumBylocator.- Parameters:
locator- the Selenium locator for the text element
-
Text
Constructor that initializes a `Text` element using a SeleniumBylocator and a name.- Parameters:
locator- the Selenium locator for the text elementname- the name of the text element
-
Text
public Text(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes a `Text` element using aSelenideElement.- Parameters:
selenideElement- the Selenide element representing the text element
-
Text
Constructor that initializes a `Text` element using aSelenideElementand a name.- Parameters:
selenideElement- the Selenide element representing the text elementname- the name of the text element
-
-
Method Details
-
$text
-
$text
-
$text
-
$text
-
$text
-
$text
-
_$text
-
toString
-
getId
Description copied from class:UIElementRetrieves the unique identifier of the element.- Specified by:
getIdin interfaceListComponent- Overrides:
getIdin classUIElement- Returns:
- the ID if explicitly set; otherwise, the text content of the root element
-