Package allurium.inputs
Class TextField
java.lang.Object
allurium.primitives.UIElement
allurium.inputs.AbstractInputElement
allurium.inputs.TextField
- All Implemented Interfaces:
AlluriumElement,InputElement,ListComponent,TextInputAsserts,WebElementMeta,Writable
- Direct Known Subclasses:
AbstractRequiredTextField,TextArea
Represents a text input field in the UI, extending
AbstractInputElement.
This class provides wrapper functionality for managing text input fields and logging each action as a step in Allure reports.
Features:
- Typing, clearing, and retrieving text from input fields.
- Assertions for input values, including checks for emptiness or specific values.
- All actions are logged as Allure steps for enhanced reporting.
Example Usage:
<html>
<input type="text">
</html>
TextField textField = new TextField("input");
textField.write("Hello World");
textField.clear();
Purpose:
- Encapsulates text input field behavior.
- Standardizes interactions with input fields for consistency in tests.
-
Field Summary
Fields inherited from class allurium.primitives.UIElement
assignNameMethod, description, id, parent, root, stepsConsoleLoggingEnabled, stepsReportLoggingEnabled, uiElementName, uiElementType -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.TextField(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes a text field using a Selenide element.Constructor that initializes a text field using a Selenide element and a name.Constructor that initializes a text field using a Selenide locator string.Constructor that initializes a text field using a Selenide locator string and a name.TextField(org.openqa.selenium.By locator) Constructor that initializes a text field using a SeleniumBylocator.Constructor that initializes a text field using a SeleniumBylocator and a name. -
Method Summary
Modifier and TypeMethodDescriptionstatic TextField_$textField(String xpath) Creates a text field instance using an XPath string.static TextField$textField(com.codeborne.selenide.SelenideElement selenideElement) Creates a text field instance using a Selenide element.static TextField$textField(com.codeborne.selenide.SelenideElement selenideElement, String name) Creates a text field instance using a Selenide element and a name.static TextField$textField(String selenideLocator) Creates a text field instance using a Selenide locator string.static TextField$textField(String selenideLocator, String name) Creates a text field instance using a Selenide locator string and a name.static TextField$textField(org.openqa.selenium.By locator) Creates a text field instance using a SeleniumBylocator.static TextField$textField(org.openqa.selenium.By locator, String name) Creates a text field instance using a SeleniumBylocator and a name.voidassertCurrentValue(String value) Asserts that the current value of the text field matches the specified value.voidassertCurrentValueContains(String value) Asserts that the current value of the text field contains the specified substring.voidAsserts that the text field is empty.voidAsserts that the text field is not empty.voidclear()Clears the text field.voidclearAndWrite(String text) Clears the text field and writes the specified text.getId()Retrieves the unique identifier for the text field.voidSimulates pressing the Enter key in the text field.value()Retrieves the current value of the text field.voidWrites the specified text into the text field.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, 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
-
TextField
public TextField()Default constructor. Initializes the element type as "input". -
TextField
Constructor that initializes a text field using a Selenide locator string.- Parameters:
selenideLocator- the Selenide locator as a string
-
TextField
Constructor that initializes a text field using a Selenide locator string and a name.- Parameters:
selenideLocator- the Selenide locator as a stringname- the name of the text field
-
TextField
public TextField(org.openqa.selenium.By locator) Constructor that initializes a text field using a SeleniumBylocator.- Parameters:
locator- the Selenium locator for the text field
-
TextField
Constructor that initializes a text field using a SeleniumBylocator and a name.- Parameters:
locator- the Selenium locator for the text fieldname- the name of the text field
-
TextField
public TextField(com.codeborne.selenide.SelenideElement selenideElement) Constructor that initializes a text field using a Selenide element.- Parameters:
selenideElement- the Selenide element representing the text field
-
TextField
Constructor that initializes a text field using a Selenide element and a name.- Parameters:
selenideElement- the Selenide element representing the text fieldname- the name of the text field
-
-
Method Details
-
$textField
Creates a text field instance using a SeleniumBylocator.- Parameters:
locator- the Selenium locator for the text field- Returns:
- a new
TextFieldinstance
-
$textField
Creates a text field instance using a SeleniumBylocator and a name.- Parameters:
locator- the Selenium locator for the text fieldname- the name of the text field- Returns:
- a new
TextFieldinstance
-
$textField
Creates a text field instance using a Selenide element.- Parameters:
selenideElement- the Selenide element representing the text field- Returns:
- a new
TextFieldinstance
-
$textField
public static TextField $textField(com.codeborne.selenide.SelenideElement selenideElement, String name) Creates a text field instance using a Selenide element and a name.- Parameters:
selenideElement- the Selenide element representing the text fieldname- the name of the text field- Returns:
- a new
TextFieldinstance
-
$textField
Creates a text field instance using a Selenide locator string.- Parameters:
selenideLocator- the Selenide locator as a string- Returns:
- a new
TextFieldinstance
-
$textField
Creates a text field instance using a Selenide locator string and a name.- Parameters:
selenideLocator- the Selenide locator as a stringname- the name of the text field- Returns:
- a new
TextFieldinstance
-
_$textField
Creates a text field instance using an XPath string.- Parameters:
xpath- the XPath string for the text field- Returns:
- a new
TextFieldinstance
-
write
Writes the specified text into the text field.Step: Processed by Aspect
-
clearAndWrite
Clears the text field and writes the specified text.- Parameters:
text- the text to be typed after clearing the field
-
clear
public void clear()Clears the text field.Step: Processed by Aspect
-
value
Retrieves the current value of the text field.- Returns:
- the current value of the text field
-
pressEnter
public void pressEnter()Simulates pressing the Enter key in the text field. -
assertEmpty
public void assertEmpty()Asserts that the text field is empty. = Step: Processed by Aspect =- Specified by:
assertEmptyin interfaceTextInputAsserts- Overrides:
assertEmptyin classUIElement
-
assertNotEmpty
public void assertNotEmpty()Asserts that the text field is not empty.Step: Processed by Aspect
- Specified by:
assertNotEmptyin interfaceTextInputAsserts
-
getId
Retrieves the unique identifier for the text field.- Specified by:
getIdin interfaceListComponent- Overrides:
getIdin classUIElement- Returns:
- the ID or name of the text field
-
assertCurrentValue
Asserts that the current value of the text field matches the specified value.Step: Processed by Aspect
- Specified by:
assertCurrentValuein interfaceTextInputAsserts- Specified by:
assertCurrentValuein interfaceWritable- Parameters:
value- the expected value
-
assertCurrentValueContains
Asserts that the current value of the text field contains the specified substring.Step: Processed by Aspect
- Specified by:
assertCurrentValueContainsin interfaceTextInputAsserts- Specified by:
assertCurrentValueContainsin interfaceWritable- Parameters:
value- the substring to check for
-