Search code examples
testingsapui5right-clicklong-press

UI5 - OPA5 tests - simulate "right click" or "long press" or "context menu"


I am beginning with OPA5 tests in UI5 and I created a context menu that is shown when a button, label or an image is right-clicked or if user holds it on touch screen.

Now I need to write an OPA5 test for this. I can perform left-click using new sap.ui.test.actions.Press() but I am not able to do right-click or long-press.

https://sapui5.hana.ondemand.com/#/api/sap.ui.test.actions/overview

Can someone help, please?

I believe I would be able to write it in jQuery. And as UI5 is based on jQuery there should be a way but I do not know how to combine jQuery and UI5.


Solution

  • If your Control has an event for RightClick, Hold etc. you should be able to call this Event in an Opa test somehow like:

                    iRightClickMyControl: function () {
                        return this.waitFor({
                            id: "myControlId",
                            viewName: "myView",
                            actions: function (oControl) {
                                oControl.RightClick();
                            }
                            errorMessage: "myControl was not found."
                        });
                    }
    

    See "Writing Your Own Action" in https://openui5.hana.ondemand.com/#/topic/8615a0b9088645ae936dbb8bbce5d01d