Overview
The Check Visibility step verifies whether elements on your page are visible or hidden. It’s essential for testing UI states, conditional content, loading indicators, modals, and any interface element that toggles between visible and hidden states.When to Use Check Visibility
Use Check Visibility when you need to:- Verify modals and dialogs appear: Confirm confirmation dialogs, alerts, or overlays display when expected
- Check loading states: Ensure loading spinners appear during operations and disappear when complete
- Test conditional UI: Verify elements show or hide based on user actions or application state
- Validate responsive behavior: Check that mobile menus, dropdowns, or collapsible sections work correctly
- Confirm error states: Verify error banners appear when needed and clear when resolved
How It Works
Check Visibility finds an element using a CSS selector and determines if it’s visible to a user. An element is considered visible if it exists in the page and isn’t hidden by CSS properties likedisplay: none or visibility: hidden.
Unlike Check Text which verifies what content an element contains, Check Visibility only cares about whether the element can be seen. This makes it perfect for testing UI state changes, animated elements, and conditional content that appears or disappears.
Using the Check Visibility Step
When you add a Check Visibility step, you’ll configure:Finding Your Element
Use the element picker to visually select your target element, or enter a CSS selector directly. Make sure your selector identifies the specific element whose visibility you’re testing - not a parent container that might always be visible.Choosing Your Assertion
Check Visibility supports two types of verification: Is Visible (Default) Confirms the element appears on the page and isn’t hidden. Perfect for verifying that content, messages, or UI elements display when they should. Is Not Visible Confirms the element is either hidden or doesn’t exist in the page. Ideal for checking that loading states clear, error messages disappear, or modals close properly.Real-World Examples
Confirming a Modal Opens
Verifying Loading State Clears
Testing Error Message Display
Checking Mobile Menu State
Verifying Success Banner Appears
Best Practices
Write Specific Selectors
- Target the exact element you’re testing:
[data-testid='confirmation-modal'] - Avoid parent containers that might always be visible:
.modal-wrapper - Use stable selectors that won’t break with layout changes
Choose the Right Assertion
- Use “Is visible” to confirm elements appear when they should
- Use “Is not visible” to confirm elements hide when they should
- Remember: “Is not visible” passes whether the element is hidden OR doesn’t exist
Understand Visibility States
Elements are considered visible when:- They exist in the DOM
- They have visible dimensions (height and width)
- They’re not hidden by CSS (
display: none,visibility: hidden)
- They don’t exist in the DOM at all
- They have
display: noneorvisibility: hidden - They have zero dimensions
opacity: 0.
Handle Timing Correctly
- Add Wait for Element steps before visibility checks for dynamic content
- Account for CSS animations and transitions
- For elements that toggle quickly, ensure your test timing matches the UI behavior
Combine with Other Steps
Check Visibility works great with other steps:- After a Click, verify the expected UI change occurred
- Before a Fill, confirm the input field is visible
- Use Check Text after visibility checks to verify content
Troubleshooting
Unexpected “Not Visible” Results
Symptom: Test says element is not visible when you can see it Solution:- Check if the element has
opacity: 0or is positioned off-screen (still considered visible) - Verify your selector targets the right element (use the element picker)
- Check if animations or transitions affect visibility detection
Timing Issues
Symptom: Visibility check runs before the element appears or hides Solution:- Add a Wait for Element step first
- Account for CSS transition/animation duration
- For fast UI changes, ensure your test sequence matches the timing
Hidden vs. Non-Existent
Symptom: Unsure whether element is hidden or missing entirely Solution:- Both hidden and non-existent elements pass “Is not visible” checks
- Use browser dev tools to check if element exists in the DOM
- Consider whether your test should differentiate between hidden and missing
Parent Container Confusion
Symptom: Visibility check passes but the wrong element is being tested Solution:- Ensure your selector targets the specific element, not a wrapper
- Use the element picker to confirm you’re selecting the right element
- Check that the element you’re testing actually changes visibility
Related Steps
- Wait for Element - Wait for elements before checking visibility
- Check Text - Verify content of visible elements
- Click - Interact with visible elements
- Fill - Enter text into visible input fields

