on ‎2023 May 15 9:33 AM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I didnt want to program the MessageToast himself.
I already have one but I want to test it with WdI5
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.