Asserts that the target element is fully centered both horizontally and vertically within the specified container element.
┌─────────────────┐ │ │ │ ┌─────────┐ │ │ │ element │ │ │ └─────────┘ │ │ │ └─────────────────┘ Copy
┌─────────────────┐ │ │ │ ┌─────────┐ │ │ │ element │ │ │ └─────────┘ │ │ │ └─────────────────┘
The element as a Locator to check for centering.
The container element as a Locator relative to which centering is checked.
Optional centering options.
A Promise that resolves with the matcher result.
// Check that a modal is perfectly centered within the viewport, allowing a 2% marginconst parentLocator = page.locator('#parent');await expect(modalLocator).toBeFullyCentered(parentLocator, { tolerance: 2, toleranceUnit: ToleranceUnit.Percent}); Copy
// Check that a modal is perfectly centered within the viewport, allowing a 2% marginconst parentLocator = page.locator('#parent');await expect(modalLocator).toBeFullyCentered(parentLocator, { tolerance: 2, toleranceUnit: ToleranceUnit.Percent});
Asserts that the target element is fully centered both horizontally and vertically within the specified container element.