Search code examples
sapui5

How Validation can happen for a Message Toast popup text in OPA5 test Framework?


Here is my code :

function() {
     this.waitFor({
         matchers: function() {
             console.log(jQuery(".sapMMessageToast").text());
             return (jQuery(".sapMMessageToast").text() === "Hello World");
         },
         success: function() {
             Opa5.assert.ok(true, "Pop Message Toast is coming Successfully");
         },

         errorMessage: "No Toast message detected!"
     });
}

Output :-

Getting Error as :-

No Toast message detected! Opa timeout This is what Opa logged: all results were filtered out by the matchers - skipping the check - sap.ui.test.pipelines.MatcherPipeline Callstack: at f.e.waitFor at @ 14574 ms Expected:
true Result:
false Diff:
trufalse

So here jQuery(".sapMMessageToast").text() statement returning "" , instead of Hello World (Actual Message popup by app), so control is going to error condition .


Solution

  • if you look at the API here

    function options.check?
    Will get invoked in every polling interval. If it returns true, the check is successful and the polling will stop. The first parameter passed into the function is the same value that gets passed to the success function. Returning something other than boolean in check will not change the first parameter of success.

    Basically you have to define a check function to look up the MessageToast to see whether it is showing or not.

    Hope it helps.