Skip to content

Assert Actions

sapAssertElementTextContains

Since: 3.0

Description: Assert that an element contains the specified text.

Input Format: Text value to assert (e.g., Success)

ObjectName Action Input Condition Reference
SAP 🟢 sapAssertElementTextContains @value ⬅ Hardcoded Input
SAP 🟢 sapAssertElementTextContains Sheet:Column ⬅ Input from Datasheet
SAP 🟢 sapAssertElementTextContains %dynamicVar% ⬅ Input from variable
@Action(object = ObjectType.SAP, desc = "Assert that [<Object>] contains Text [<Data>]", input = InputType.YES)
public void sapAssertElementTextContains() {
    try {
        String actual = Dispatch.get(SAPelement, "Text").toString();
        if (actual.contains(Data)) {
            Report.updateTestLog(Action, "Element contains text [" + Data + "]", Status.DONE);
        } else {
            Report.updateTestLog(Action, "Element does not contain text [" + Data + "]", Status.FAIL);
        }
    } catch (Exception e) {
        Report.updateTestLog(Action, "Failed to assert text. Error: " + e.getMessage(), Status.FAILNS);
    }
}