Playwright Wait Until Element is Visible

In playwright, we can ensure whether an element is visible using the waitFor method. This article will discuss how we can assert the visibility of an element in a playwright.


(method) Locator.waitFor(options?: {
    state?: "visible" | "attached" | "detached" | "hidden" | undefined;
    timeout?: number | undefined;
} | undefined): Promise<void>


const ele = page.locator("#myDiv");
await ele.waitFor({state: "visible"})


const locator = page.locator('element');
await expect(locator).toBeVisible();
Wed, 01/04/2023 - 11:33
Ashwin possesses over five years of experience in the Quality Assurance industry and is currently serving as a Technical Lead at iVagus. His expertise encompasses a broad range of technologies, including Cypress, Rest Assured, Selenium, Cucumber, JavaScript and TypeScript.