Class Actions.GetElementInformation

java.lang.Object
com.shaft.gui.element.internal.Actions.GetElementInformation
Enclosing class:
Actions

public class Actions.GetElementInformation extends Object
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 Type
    Method
    Description
    attribute(@NonNull org.openqa.selenium.By locator, @NonNull String attributeName)
    Returns the value of the named HTML attribute from the located element.
    cssValue(@NonNull org.openqa.selenium.By locator, @NonNull String propertyName)
    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.
    boolean
    isDisplayed(@NonNull org.openqa.selenium.By locator)
    Returns true if the located element is currently displayed on the page.
    boolean
    isEnabled(@NonNull org.openqa.selenium.By locator)
    Returns true if the located element is currently enabled (i.e., interactive).
    boolean
    isSelected(@NonNull org.openqa.selenium.By locator)
    Returns true if 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.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 element
      attributeName - the name of the HTML attribute to read
      Returns:
      the attribute value, or null if 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 element
      attributeName - the name of the DOM attribute to read
      Returns:
      the DOM attribute value, or null if 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., value for an input) rather than the original HTML attribute.

      Parameters:
      locator - the locator for the target element
      propertyName - the name of the DOM property to read (e.g., "value")
      Returns:
      the property value as a string, or null if the property is absent
    • name

      @Step("Get name") public String name(@NonNull @NonNull org.openqa.selenium.By locator)
      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

      @Step("Get text") public String text(@NonNull @NonNull org.openqa.selenium.By locator)
      Returns the visible inner text of the located element.

      Falls back to the textContent DOM property and then the value DOM 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 element
      propertyName - 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)
      Returns true if the located element is currently displayed on the page.
      Parameters:
      locator - the locator for the target element
      Returns:
      true if the element is visible; false otherwise
    • isEnabled

      @Step("Get is enabled") public boolean isEnabled(@NonNull @NonNull org.openqa.selenium.By locator)
      Returns true if the located element is currently enabled (i.e., interactive).
      Parameters:
      locator - the locator for the target element
      Returns:
      true if the element is enabled; false if it is disabled
    • isSelected

      @Step("Get is selected") public boolean isSelected(@NonNull @NonNull org.openqa.selenium.By locator)
      Returns true if the located element (e.g., a checkbox or radio button) is currently selected.
      Parameters:
      locator - the locator for the target element
      Returns:
      true if the element is selected; false otherwise