Testery Docs
TesteryFeaturesPricingRelease Notes
  • Testery Documentation
  • Release Notes
  • Get Started
    • Getting Started Guide
      • Create a Testery Account
      • Configure Your Project
      • Run Your Tests
      • Configure Slack Alerts
      • Schedule Your Test Runs
      • Invite Your Team
      • Get More From Testery
  • Get to Know Testery
    • Dashboard
    • Test Runs
      • Test Selection Rules
    • Projects
    • Test Triggers
    • Environments
    • Alerts
    • Settings
    • Test Plans
    • Test Stacks
      • Python
      • Node.js 16 End of Life
      • Default Chrome Version Change
      • Python 3.8 End of Life
    • Deployments
    • System Variables
    • Tags
    • Screenshots
    • Uploading Test Artifacts to Testery
    • Setting Test Execution Priority
    • Setting the Number of Parallel Tests
  • Integrate with Testery
    • Built-In Integrations with Testery
      • Jira
      • Slack
    • CI/CD Integration Guides
      • Azure Devops Pipelines
      • Set Up CircleCI to Run Testery Tests
      • Jenkins
      • GitHub Actions
      • Octopus Deploy
      • TugboatQA
    • Testery CLI
    • Testery REST API
      • Testery REST API Resources
    • Microsoft Teams
  • Framework-specific Guidance
    • Supported Testing Frameworks
    • Cypress
      • Updating Cypress Tests to Output in JUnit XML Format
    • Playwright
      • Update Playwright Tests to Output in JUnit XML Format for Import Into Testery
    • PyTest
      • Update Pytest to Generate JUnit XML for Import into Testery
    • TestNG
      • Updating TestNG Tests to Output in JUnit XML Format
  • How-To
    • Enable or Disable Automatic Rerunning of Tests
    • Run Cypress Tests without Connecting Repository
    • How to Store Sensitive Data Like Username and Password For a Cypress Test
    • Connect to a Private npm Repository
    • Running Scripts Before the Tests
    • Upload Test Run for Analysis
  • MISC
    • Troubleshooting Steps
  • Fixing Tests
    • Fix Common Selenium Exceptions
      • Fix a ChromeDriver Version Exception
      • Fix a NoSuchElement Exception
      • Fix a TimeoutException
      • Fix an ElementNotVisibleException
      • Fix a StaleElementReferenceException
      • Fix a WebDriverException
      • Fix an InvalidArgumentException
      • Fix a NoSuchWindowException
      • Fix an UnhandledAlertException
      • Fix an InvalidSelectorException
Powered by GitBook
On this page

Was this helpful?

  1. Fixing Tests
  2. Fix Common Selenium Exceptions

Fix an ElementNotVisibleException

The ElementNotVisibleException, occurs when you attempt to interact with an element on a web page that is present in the DOM (Document Object Model) but not visible or interactable to the user. Several reasons can lead to this exception:

  1. CSS Properties: The element's CSS properties, such as "display: none" or "visibility: hidden," may be set in a way that makes it invisible on the web page. This often happens with elements that are initially hidden and become visible only after specific user interactions or events.

  2. Hidden Elements: Some elements, such as certain pop-ups or dropdown menus, may be hidden by default and become visible only when triggered by user actions like clicking or hovering. Attempting to interact with such elements before they are made visible can result in the ElementNotVisibleException.

  3. Element Overlapping: Another element may be covering the element you are trying to interact with, making it effectively invisible or inaccessible. This can happen with elements that share the same screen space or have overlapping positions.

  4. Dynamic Content Loading: The web page might be using dynamic content loading techniques, such as AJAX, which means that certain elements might not be visible until they are loaded asynchronously. If Selenium tries to interact with the element before it becomes visible, it can lead to this exception.

To handle the ElementNotVisibleException effectively, consider the following strategies:

  • Ensure that the element is genuinely supposed to be visible at the time you are trying to interact with it. Verify the element's visibility status in the HTML/CSS or through browser developer tools.

  • Use explicit waits with the WebDriverWait class to wait for the element to become visible before interacting with it. You can specify conditions like ExpectedConditions.visibilityOfElementLocated.

  • If the element is expected to become visible after a user action, simulate that action (e.g., clicking a button) before attempting to interact with the element.

  • Check for overlapping elements that might be preventing access to the element you want to interact with and ensure proper ordering or z-index settings.

  • Handle dynamic content loading scenarios by waiting for the element to appear using explicit waits.

By addressing these issues and implementing proper synchronization and validation mechanisms, you can avoid or handle the ElementNotVisibleException in your Selenium test automation effectively.

PreviousFix a TimeoutExceptionNextFix a StaleElementReferenceException

Last updated 1 year ago

Was this helpful?