cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Testing a MessageToast with WDI5

former_member858416
Discoverer
701

Hi everyone,

I am currently working on an application and would like to test it now.

When clicking a button the user gets a MessageToast as a response and I wanted to test this now.

I tried to initialize the control as follows:

const messageToast = await browser.asControl({

selector: {

controlType: "sap.m.MessageToast",

viewId: "...testApp.view.Main"

id: "messageToast"

}

});

But now I noticed that this UI5 control is not found.

Therefore my question was, if it is not possible to test a MessageToast with wdi5.

Thanks a lot for the answer.

With kind regards

Accepted Solutions (0)

Answers (1)

Answers (1)

sergiorecasens
Participant

Hi,

First, you must define a listener for the 'press' event of the button. You can do this in the XML view as follows:

<Button text="Save" width="auto" enabled="true" visible="true" press="onSaveButton" />

Then, in your controller class, import the MessageToast library and define the 'onSaveButton' method as follows:

sap.ui.define(["sap/ui/core/mvc/Controller", "sap/m/MessageToast"], 
function (BaseController, MessageToast,) {
    "use strict";
    return BaseController.extend("com.sap.test.controller.MainView", {
		onSaveButton: function (oEvent) {
			MessageToast.show("This is a Message Toast", {
				duration: 8000,
				autoClose: true
				// here you can add more properties of MessageToast
			});
		}
    });
});

Check the properties of a MessageToast in the API:

https://sapui5.hana.ondemand.com/sdk/#/api/sap.m.MessageToast

More samples for MessageToast:

https://sapui5.hana.ondemand.comsdk/#/entity/sap.m.MessageToast

former_member858416
Discoverer

I didnt want to program the MessageToast himself.
I already have one but I want to test it with WdI5