Element has class
Function: Element has class
This action helps you determine if a specific visual component (UI element) on your application screen currently has a particular style class applied to it. It's useful for checking the current state or appearance of an element without needing to write any code.
Input
- Element:
- Type: UI element
- Description: The specific visual component on your page that you want to inspect. This could be a button, a text field, an image, or any other part of your user interface.
- Required: Yes
- Class:
- Type: Text
- Description: The exact name of the style class you are looking for on the selected UI element (e.g., "active", "hidden", "error").
- Required: Yes
Output
- Result:
- Type: True/False
- Description: A True/False value indicating whether the specified class was found on the element. This value will be stored in a variable named 'RESULT' by default, but you can change this name to something more descriptive for your application.
Execution Flow
Real-Life Examples
Here are some practical ways you can use the "Element has class" action in your application:
Example 1: Conditional Visibility of a Section
Imagine you have a "Details" section that can be expanded or collapsed, and its visibility is controlled by a collapsed class. You want to check if it's currently collapsed.
- Inputs:
- Element:
Details Section(the UI element representing the section) - Class:
collapsed - Result:
isSectionCollapsed
- Element:
- Result: The variable
isSectionCollapsedwill beTrueif the "Details Section" currently has thecollapsedclass, meaning it's hidden. It will beFalseif the class is not present, meaning the section is expanded. You can then useisSectionCollapsedto decide whether to show an "Expand" or "Collapse" button.
Example 2: Validating Form Input State
You have an email input field, and when the user enters an invalid email, an invalid-input class is added to highlight the error. You want to check this state before submitting the form.
- Inputs:
- Element:
Email Input Field(the UI element for email entry) - Class:
invalid-input - Result:
emailHasError
- Element:
- Result: The variable
emailHasErrorwill beTrueif theEmail Input Fieldhas theinvalid-inputclass, indicating an error. It will beFalseif the input is valid. You can useemailHasErrorto prevent form submission or display an error message.
Example 3: Checking Active Navigation Item
In a navigation menu, the currently selected item might have an active class. You want to confirm which menu item is active to perform a specific action.
- Inputs:
- Element:
Dashboard Menu Item(the UI element for the dashboard link) - Class:
active - Result:
isDashboardActive
- Element:
- Result: The variable
isDashboardActivewill beTrueif theDashboard Menu Itemhas theactiveclass, confirming it's the currently selected page. It will beFalseotherwise. This could be used to enable or disable certain actions based on the current page.