Employing the toBeVisible
:
const elementLocator = page.locator('.my-element');
await expect(elementLocator).toBeVisible();
Utilizing the toBeInViewport
:
const elementLocator = page.locator('.my-element');
await expect(elementLocator).toBeInViewport();
What distinguishes these two options? Both are aimed at verifying if the element is visible to the user.
If they serve different purposes, what scenarios would be ideal for each of them?