table of contents Table of contents

How to Fix "Element Not Visible" Error in Playwright

Knowing that an element is included in the DOM might not be enough for us to properly interact with it: its state also determines whether our action will be able to go through.

Example error message:

Terminal
ERROR - UserScript page.waitForSelector: Timeout 30000ms exceeded. 
waiting for selector ".contact-form > .form-control" to be visible
  selector resolved to hidden <element>

Possible causes

  • Obvious possible cause: the element is set to hidden while it shouldn’t. Something is wrong with the element itself.
  • Not-so-obvious possible cause: a different element is hiding the target element without our knowledge.

How to avoid confusion

Either walk through the execution in headful mode or take screenshots before and after the instruction that has raised the error - this will help you verify whether the application state actually is the one you expect.

Note that this list neither is nor aims to be complete: additional possible causes most likely exist for this error.


Last updated on December 9, 2024. You can contribute to this documentation by editing this page on Github