Assert equals two assertion

Viewed 29

The problem: sometimes I have to check element value using getAttribute("value)" instead of getText. I'd like to assert result of getText or getValue with provided text.

What's best practice? Create two separate method with checking values, one with Assert.assertEquals(text,generalUtils.getTextValue(selector)); and second Assert.assertEquals(text,generalUtils.getAttributeValue(selector));

Or somehow in method like bellow check if only one assertion is true and the second could be false?

  public void checkIfValueIsTheSame(By selector, String text) {
    LOGGER.info("Check if text match on element");
    await().atMost(5, SECONDS).until(() -> {
        Assert.assertEquals(text,generalUtils.getTextValue(selector));
        Assert.assertEquals(text,generalUtils.getAttributeValue(selector));
        return true;
    });
}
0 Answers
Related