Skip to content

Get Style Attribute of Locator: getStyleAttribute

The Get Style Attribute of Locator function retrieves the specified CSS style attribute (e.g., color, background color, or border color) of a UI element identified by a locator. This function is useful for verifying UI properties in automation workflows.

Example Usage: Suppose you want to check the background color of a button on the login page to ensure it meets UI design requirements.

Steps to Configure:

  1. Select Set a Variable Value from the Action dropdown.
  2. In the Element Key field, enter a variable name to store the retrieved attribute value (e.g., ButtonColor).
  3. In the Parameter section, click Form and select Functions from the dropdown.
  4. Choose Get Style Attribute of Locator from the list of functions.
  5. Provide the following values:
    • Page Name: Enter the name of the page where the element is located (e.g., LoginPage). Ensure that the page name is already defined before using this function.
    • Locator Key: Enter the locator key to identify the UI element (e.g., LoginButton).
    • Attribute: Select the style attribute to retrieve from the dropdown. The available options are:
      • Color
      • Background-color
      • Border-color
  6. Click Save.

Note: While the steps for adding an  command are identical in both views, the display of the steps changes:

scrn-get-style-attribute-tabular-view
Tabular View
scrn-get-style-attribute-card-view
Card View

Expected Outcome

  • The retrieved style attribute value (e.g., rgb(0, 128, 255)) is stored in the specified variable.
  • This value can be used in subsequent steps using the syntax ${VariableName}

(e.g., ${ButtonColor}).

Back To Top