Playwright Python: expect(locator).to_be_visible() vs locator.wait_for()

  Kiến thức lập trình

Is there a difference between expect(locator).to_be_visible() and locator.wait_for()? Should I prefer one over the other?

I’ve looked up the __doc__s:

  • wait_for: Returns when element specified by locator satisfies the state option. (state defaults to 'visible').
  • to_be_visible: Ensures that Locator points to an attached and visible DOM node.

Still, not very clear. Is it possible for a locator to be visible but not attached? If so, would they be equal if I know for sure that the located element is attached?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT