Code Monkey home page Code Monkey logo

Comments (2)

RunOrVeith avatar RunOrVeith commented on March 22, 2025 1

I understand that it's not planned to address the timing issues on your side, but I would like to at least get some documentation about the fact that all locators ignore invisible elements completely.

To me it is also surprising that the following page

<div>
    <button
        name="senddata"
        style="display: none;"
        >
        <span>Agree to all</span>
    </button>
    <button
        name="senddata"
    >
        <span>Agree to all</span>
    </button>
</div>

with this locator call page.getByRole('button', { name: 'Agree to all' }).click() does not raise a strict mode violation.
Especially since there is a special section in the documentation that is telling you exactly the opposite should be the case. This seems very inconsistent to me.

from playwright.

yury-s avatar yury-s commented on March 22, 2025

The locator generator acts based on the current state of the page, it doesn't know if one of currently invisible elements will become visible or a new element matching same locator is going to be added by javascript later (or the order of elements may change etc.). If you know that the locator is not going to be unique, you can call the generator when the page is in appropriate state or you can always alternate the result to be more resilient to changes in the page.

Closing this issue as not planned.

from playwright.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.