Asserts that the target element is fully centered both horizontally and vertically within the specified container element.
|-----------------| | | | [element] | | | |-----------------| Copy
|-----------------| | | | [element] | | | |-----------------|
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, { tolerancePercent: 2}); Copy
// Check that a modal is perfectly centered within the viewport, allowing a 2% marginconst parentLocator = page.locator('#parent');await expect(modalLocator).toBeFullyCentered(parentLocator, { tolerancePercent: 2});
Asserts that the target element is fully centered both horizontally and vertically within the specified container element.