Open
Description
With assertJ, we can add a custom name for given asserted object, for example:
Assertions.assertThat(mansion.guests()).as("Living Guests").isEqualTo(7);
Will result in:
[Living Guests] expected:<[7]> but was<[6]>
Selenide comes with element-aliasing as well as the .because()
call (that does the similar thing, but not on asserted element, but the assertion itself):
$("div >> span").as("Living Guests").shouldHaveSize(7).because("The guest count should be valid")
The playwright-java assertions would be more readable if we'd be able to do similar thing with PlaywrightAssertions.assertThat
or even the Locator
/Page
/ApiResponse
itself, e.g.:
// on assertion:
PlaywrightAssertions.assertThat(questCount).hasText("7").because("The guest count should be valid");
// on asserted object:
PlaywrightAssertions.assertThat(questCount).as("Living Guests").hasText("7");
// on Locator
Locator guestCount = page.locator("div >> span").as("Living Guests");