I have a mysteriously failing test, and I have some suspicion. Am I right that if there is some element on the page which is hidden (via display: none
) and it's shown after some time (less than the timeout, but still), then
await expect(locator).toBeVisible();
will (may?) fail, but
await locator.waitFor({state: 'visible'});
will work? Also, do I get it right that if I use the latter, there's no need to assert the visibility of that element after that?
This thread is trying to answer question "What is the difference between using expect and waitFor to check if an element is visible, and will expect fail if the element is hidden at first?"
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].