Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk3 min

How to Set Locator Visibility in Puppeteer

Use Puppeteer’s locator.setVisibility() to configure visibility checks for an action. Learn when null disables the check and when waitForSelector() is the better fit.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use locator.setVisibility(value) to configure whether a Puppeteer locator waits for an element to be visible or hidden before an action. For example, .setVisibility(null) disables that visibility check. It changes the locator’s action behavior—not the element’s CSS or actual visibility on the page.

Set a locator’s visibility check

Call setVisibility() on a locator created with page.locator() or frame.locator(). The method returns a cloned locator with the visibility setting changed, so chain the returned locator into the action:

As an Amazon Associate I earn from qualifying purchases.

await page
  .locator('button')
  .setVisibility(null)
  .click();

Here, null disables the locator’s visibility check. It does not reveal the button, change its CSS, or guarantee that the click will succeed. Puppeteer’s Locator.setVisibility() reference documents the method and its return type; the API reference defines the accepted visibility option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a visibility value when you want the locator to check state

The visibility option configures whether the locator waits for the element to be visible or hidden before the action. Use the value appropriate to the state your interaction requires; use null only when you specifically want to disable this check.

Locators are Puppeteer’s recommended way to select and interact with elements. They automatically wait for elements to be present and in the right state for an action. The Page interactions guide also lists viewport, visibility, enabled state, and a stable bounding box among click preconditions. Disabling visibility checking removes that check only; it does not disable every other precondition.

Choose between setVisibility() and waitForSelector()

These APIs address related but different tasks. Use setVisibility() to configure a locator action’s visibility check. Use waitForSelector() when you need an explicit wait for a selector’s DOM or visibility state and want to work with the resulting element handle.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
API Use it for Result
locator.setVisibility(value) Configuring the visibility check for a locator action A locator with the changed setting
page.waitForSelector(selector, options) Explicitly waiting for a selector to appear or become visible or hidden An element handle, or null when a hidden selector is not found

For waitForSelector(), visible: true waits for the element to be in the DOM and not use display: none or visibility: hidden. hidden: true waits until the element is absent or hidden by those CSS properties. The documented default timeout is 30,000 ms; change the default with Page.setDefaultTimeout(). See the waitForSelector() API reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common problems and fixes

  • The element is still hidden. setVisibility(null) does not modify page styling. If you need it to become visible, change the page state or its CSS; disabling the locator check alone will not do that.
  • The action still fails after disabling visibility checks. Visibility is only one possible action precondition. Check whether the element is in the viewport, enabled, and has a stable bounding box, and confirm that the selector identifies the intended element.
  • You need to wait for a state before continuing. Use waitForSelector() with its visible or hidden option rather than treating setVisibility() as a standalone wait.
  • An explicit wait times out. The default timeout is 30,000 ms. Verify the selector and expected state, then adjust the timeout with Page.setDefaultTimeout() if the page legitimately takes longer.

Documentation version

The cited Locator, interactions, and wait-for-selector documentation identifies Puppeteer version 25.12.0. If you use a different release, check its API reference for the applicable signature and defaults. The documented behavior here is not a claim about browser-specific testing.

Rank #3
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a screenshot rather than configuring a Puppeteer interaction, ScreenshotNeo can capture a page through one GET request. It does not set locator visibility or replace Puppeteer automation; it is an alternative for screenshot capture.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo documentation for request options. It removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.