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.

[BUG] Logs say element is visible, but get the error 'Element is not visible' when using force click

See original GitHub issue

Context:

  • Playwright Version: ^1.16.3
  • Operating System: Windows
  • Node.js version: 14.17.0
  • Browser: Chromium, Firefox

Code Snippet

//element not visible with standard click (though a user can see it on the page)
await frame.locator('[data-unique-id="Ribbon-TableStyles"]').click();
.
.
locator.click: Target closed
    =========================== logs ===========================
    waiting for selector "[data-unique-id="Ribbon-TableStyles"]"
      selector resolved to hidden <div aria-label="Table Styles" class="galleryContaine…>…</div>
    attempting click action
      waiting for element to be visible, enabled and stable
        element is not visible - waiting...
    ============================================================
.
.
.
.
//element visible when using force, but still doesn't click
await frame.click('[data-unique-id="Ribbon-TableStyles"]', { force: true });
.
.
frame.click: Element is not visible
    =========================== logs ===========================
    waiting for selector "[data-unique-id="Ribbon-TableStyles"]"
      selector resolved to hidden <div aria-label="Table Styles" class="galleryContaine…>…</div>
    attempting click action
      waiting for element to be visible, enabled and stable
        forcing action
      element is visible, enabled and stable
      scrolling into view if needed
    ============================================================

Describe the bug I am trying to click a button by using force : true to bypass the visibility check (because I don’t understand why the button is hidden during this test - it can be seen by the user when run headful). However, when I use the force option to bypass visibility check, I still get an error that the element is not visible. This is confusing, because the logs say that the element is visible when I set the force option to true.

Why would forcing the click action change the visibility of the element? And why would this error: frame.click: Element is not visible appear if the logs say the element is in fact visible? If using force click will prompt the logs to print that an element is visible even when it is not, I think that should be noted in the docs.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pavelfeldmancommented, Feb 10, 2022

Looking at the full test case, the element [data-unique-id="Ribbon-TableStyles"] has display: none until the size of the screen is > 1546

Screen Shot 2022-02-09 at 7 33 09 PM

So there is no way you can click it, it is not there in the screen. When I disable this style, I can see this element in the screen:

Screen Shot 2022-02-09 at 7 32 11 PM

So Playwright’s log is accurate:

waiting for selector "[data-unique-id="Ribbon-TableStyles"]"
      selector resolved to hidden <div aria-label="Table Styles" class="galleryContaine…>…</div>
    attempting click action
      waiting for element to be visible, enabled and stable
        element is not visible - waiting...

The other button works because it is visible. Replace your selector with [data-unique-id="Ribbon-TableStyles-ghostFlyout"] and it should work.

1reaction
pavelfeldmancommented, Feb 10, 2022

Could you share why the logs in my first post say that the element is visible but the error itself says otherwise?

It is a logging artifact. We get to that point in process either if the element passed these actionability checks, or if the action was forced.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright .NET - Element Visible but click fails - Stack Overflow
When the page opens, it throws a few pop ups which need to be closed before reading the title text. var locator =...
Read more >
How To Deal With "Element is not clickable at point” Exception ...
The exception “Element is not clickable at point” usually occurs when the WebElement we want to interact with (or click) is not clickable...
Read more >
How to Fix Selenium's "Element Is Not Clickable at Point"
The solution to avoid this is to wait until the element is loaded completely. There are different ways of doing this.
Read more >
Debug the Element Visibility Problems in Cypress
In GitHub issue #9378 the user submitted a reproducible example of a failing test. Cypress fails the test when the clearly visible "Cypress ......
Read more >
The 10 Most Common JavaScript Issues Developers Face
As JavaScript coding techniques and design patterns have become ... there were 10 input elements, clicking any of them would display “This is...
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