Class Actions.GetElementInformation
java.lang.Object
com.shaft.gui.element.internal.Actions.GetElementInformation
- Enclosing class:
Actions
Provides read-only accessors for querying properties, attributes, and state of a
located web element.
Obtain an instance via Actions.get():
String title = driver.element().get().attribute(By.id("header"), "title");
boolean visible = driver.element().get().isDisplayed(By.id("banner"));
-
Method Summary
Modifier and TypeMethodDescriptionReturns the value of the named HTML attribute from the located element.Returns the computed CSS value of the named property for the located element.domAttribute(@NonNull org.openqa.selenium.By locator, @NonNull String attributeName) Returns the value of the named DOM attribute from the located element.domProperty(@NonNull org.openqa.selenium.By locator, @NonNull String propertyName) Returns the value of the named DOM property from the located element.booleanisDisplayed(@NonNull org.openqa.selenium.By locator) Returnstrueif the located element is currently displayed on the page.booleanisEnabled(@NonNull org.openqa.selenium.By locator) Returnstrueif the located element is currently enabled (i.e., interactive).booleanisSelected(@NonNull org.openqa.selenium.By locator) Returnstrueif the located element (e.g., a checkbox or radio button) is currently selected.name(@NonNull org.openqa.selenium.By locator) Returns the accessible name of the located element as computed by the browser's accessibility tree.selectedText(@NonNull org.openqa.selenium.By locator) Returns the combined text of all currently selected<option>elements inside a<select>element.text(@NonNull org.openqa.selenium.By locator) Returns the visible inner text of the located element.
-
Method Details
-
attribute
@Step("Get Attribute") public String attribute(@NonNull @NonNull org.openqa.selenium.By locator, @NonNull @NonNull String attributeName) Returns the value of the named HTML attribute from the located element.String href = driver.element().get().attribute(By.cssSelector("a.logo"), "href");- Parameters:
locator- the locator for the target elementattributeName- the name of the HTML attribute to read- Returns:
- the attribute value, or
nullif the attribute is absent
-
domAttribute
@Step("Get DOM attribute") public String domAttribute(@NonNull @NonNull org.openqa.selenium.By locator, @NonNull @NonNull String attributeName) Returns the value of the named DOM attribute from the located element.Unlike
attribute(By, String), this method reads the live DOM attribute value rather than the initial HTML attribute value.- Parameters:
locator- the locator for the target elementattributeName- the name of the DOM attribute to read- Returns:
- the DOM attribute value, or
nullif the attribute is absent
-
domProperty
@Step("Get DOM property") public String domProperty(@NonNull @NonNull org.openqa.selenium.By locator, @NonNull @NonNull String propertyName) Returns the value of the named DOM property from the located element.DOM properties reflect the current JavaScript object state (e.g.,
valuefor an input) rather than the original HTML attribute.- Parameters:
locator- the locator for the target elementpropertyName- the name of the DOM property to read (e.g.,"value")- Returns:
- the property value as a string, or
nullif the property is absent
-
name
Returns the accessible name of the located element as computed by the browser's accessibility tree.- Parameters:
locator- the locator for the target element- Returns:
- the accessible name string, or an empty string if none is defined
-
text
Returns the visible inner text of the located element.Falls back to the
textContentDOM property and then thevalueDOM property if the element's visible text is blank (e.g., for inputs).- Parameters:
locator- the locator for the target element- Returns:
- the trimmed visible text; never
null(returns an empty string if no text is found)
-
selectedText
@Step("Get selected text") public String selectedText(@NonNull @NonNull org.openqa.selenium.By locator) Returns the combined text of all currently selected<option>elements inside a<select>element.- Parameters:
locator- the locator for the<select>element- Returns:
- the concatenated text of all selected options
-
cssValue
@Step("Get CSS value") public String cssValue(@NonNull @NonNull org.openqa.selenium.By locator, @NonNull @NonNull String propertyName) Returns the computed CSS value of the named property for the located element.String color = driver.element().get().cssValue(By.id("title"), "color");- Parameters:
locator- the locator for the target elementpropertyName- the CSS property name (e.g.,"background-color")- Returns:
- the computed CSS value as a string
-
isDisplayed
@Step("Get is displayed") public boolean isDisplayed(@NonNull @NonNull org.openqa.selenium.By locator) Returnstrueif the located element is currently displayed on the page.- Parameters:
locator- the locator for the target element- Returns:
trueif the element is visible;falseotherwise
-
isEnabled
@Step("Get is enabled") public boolean isEnabled(@NonNull @NonNull org.openqa.selenium.By locator) Returnstrueif the located element is currently enabled (i.e., interactive).- Parameters:
locator- the locator for the target element- Returns:
trueif the element is enabled;falseif it is disabled
-
isSelected
@Step("Get is selected") public boolean isSelected(@NonNull @NonNull org.openqa.selenium.By locator) Returnstrueif the located element (e.g., a checkbox or radio button) is currently selected.- Parameters:
locator- the locator for the target element- Returns:
trueif the element is selected;falseotherwise
-