How to fix Playwright "locator.click: Timeout ... element is not visible"?

Playwright

The locator exists but is hidden, covered, or outside expected UI state.

Wait for visibility and stable state before clicking.

const menu = page.getByRole('button', { name: 'Open menu' });
await menu.click();

const item = page.getByRole('menuitem', { name: 'Settings' });
await expect(item).toBeVisible();
await item.click();

If overlays block clicks, close modal/toast layers first instead of forcing clicks.