Asserts that the target element has the specified aspect ratio (width divided by height),
within an optional tolerance percentage.
This assertion calculates the aspect ratio of the element by dividing its width by its height,
then compares it to the expected ratio. If the actual ratio falls outside the allowed tolerance,
a detailed message is returned to help diagnose the discrepancy.
// Checks that the element has an aspect ratio of 16:9 exactly (no tolerance) awaitexpect(elementLocator).toHaveAspectRatio(16 / 9);
Example
// Checks that the element has an aspect ratio close to 4:3 within 3% tolerance awaitexpect(elementLocator).toHaveAspectRatio(4 / 3, { tolerancePercent:3, });
Asserts that the target element has the specified aspect ratio (width divided by height), within an optional tolerance percentage.
This assertion calculates the aspect ratio of the element by dividing its width by its height, then compares it to the expected ratio. If the actual ratio falls outside the allowed tolerance, a detailed message is returned to help diagnose the discrepancy.
The aspect ratio is defined as: