question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Node is either not visible or not an HTMLElement When Element is clearly awaited for and visible

See original GitHub issue

I am trying to click a drop down option in the app I am testing but when I attempt to click I get this error message: Error: Node is either not visible or not an HTMLElement

I was able to get the text of the element in question by calling myElementHandleInstance.getProperty('innerText') but for some reason I am unable to click the element. I have waited for the element to become visible on the screen. I even added in a 300 second sleep to make absolutely sure the element was appearing.

Tell us about your environment:

  • Puppeteer version: 1.20.0
  • Platform / OS version: MAC OS
  • URLs (if applicable): N/A
  • Node.js version: 9.5.0

What steps will reproduce the problem? I’m not sure as I can’t give you access to the site I am testing. But I will try to answer any questions that come up.

Please include code that reproduces the issue. Here is a sample of the HTML I am interacting with

<select class="jss2373 jss2385" name="state[0] aria-invalid="false">
  <option value="please-choose" selected="">Select a state</option>
  <option value="AL">Alabama</option><option value="AK">Alaska</option>
  <option value="AZ">Arizona</option><option value="AR">Arkansas</option>
  <option value="CA">California</option><option value="CO">Colorado</option>
  <option value="CT">Connecticut</option><option value="DE">Delaware</option>
  <option value="DC">District Of Columbia</option><option value="FL">Florida</option>
  ...

This is what my code is doing with this, the frame work this is set up in is a little to complex to get into here, so this is somewhat sudo code:

this.browser.click('select[name="state[0]"]') //this clicks the drop down
await this.sleep(300) //long sleep to make absolutely sure the element is on the page
selectionList = this.browser.$('select[name="state[0]"]').$$('option') //this returns an Array of ElementHandles (returns all the option elements)
await selectionList[0].getProperty('innerText') //prints Alabama when console.loged
await selectionList[0].click()  //throws error mentioned in title

What is the expected result? The element should be clicked. if I can get text from the element I should be able to click as well

What happens instead? this error gets thrown Error: Node is either not visible or not an HTMLElement

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13

github_iconTop GitHub Comments

3reactions
Rendezcommented, Oct 11, 2019

As I posted in S.O. yesterday, I was having a similar issue: https://stackoverflow.com/questions/47014724/click-visible-elements-using-puppeteer/58325214#comment-103008647

In my case, the container div had a display: none, and it was ‘shown’ so page.waitForSelector('div', { visible: true }) effectively returned true when toggled BUT, it also had some transition cycle so waiting for it to be “displayed” is what worked. I figured a more idiomatic way of checking if an element is displayed and ready to be clicked: waiting for element.hover() to be successful, retrying every second until it is, otherwise throwing.

0reactions
stale[bot]commented, Jul 25, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer in NodeJS reports 'Error: Node is either not visible ...
Example code. const puppeteer = require('puppeteer'); const initialPage = 'https://website.com/path'; const selectors = [ 'div[id$="-bVMpYP"] ...
Read more >
Node is either not visible or not an HTMLElement for ... - GitHub
this part await page.click('#sign-in-btn') throws. Error: Node is either not visible or not an HTMLElement at ElementHandle.
Read more >
Resolve CloudWatch canary error "Node is either not visible ...
Resolution. When creating a CloudWatch canary, the "Node is either not visible or not an HTMLElement" error is typically caused by: Using ...
Read more >
Puppeteer documentation - DevDocs
Puppeteer is a Node library which provides a high-level API to control Chromium ... Non visible pages, such as "background_page" , will not...
Read more >
Node is either not visible or not an HTMLElement (flaky ...
Node is either not visible or not an HTMLElement (flaky selenium test). Closed, ResolvedPublic.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found