0
votes

Im facing an Issue in OPA Testing for SAPUI5 Application.

Im trying to perform OPA Testing for a SAPUI5 View , I have created a dropdown in the View and i have writted the OPA Script for the corresponding View.

When i run the OPA Sctipt, The script which i have written is not able to select the "Item" in the Drop Down, and im getting an error by saying.. TypeError: sap.ui.test.matchers.Properties is not a constructor

Im not getting why the Applcation is not fetching sap.ui.test.matchers.Properties class

Below is the Code for the issue..

Translation.View.xml

<Select id="toolsDocType" width="100%" change="onToolsDocChange" forceSelection="true">
<items>
<core:Item text="--Select1--" key="X" enabled="false"/>
<core:Item text="Link" key="Link"/>
<core:Item text="Atatchment" key="attachment"/>
</items>
</Select>

js File

This function will start executing the test script "fillAttachment()" function

opaTest("Select Attachment", function (Given, When, Then) {
            // Arrangements
            //Given.iStartMyApp();

            //Actions
            When.onTheTranslationPage.fillAttachment();

            // Assertions
            Then.onTheTranslationPage.CustNameShouldGetFilled();
        });

After running above code the below function will starts executing.

 fillAttachment : function () {
                            return this.waitFor({
                                id:"toolsDocType",
                                actions: new Press(),
                            success: function(oSelect) {
                                this.waitFor({
                                    controlType: "sap.ui.core.Item",
                                    matchers: [
                                        new sap.ui.test.matchers.Ancestor(oSelect),
                                        new sap.ui.test.matchers.Properties({ key: "link"})
                                    ],
                                    actions: new Press(),
                                    success: function() {
                                        Opa5.assert.strictEqual(oSelect.getSelectedKey(), "Link", "Selected link");
                                    },
                                    errorMessage: "Cannot select link from mySelect"
                                });
                            },
                                errorMessage: "There was no Input"
                            });
                        },

Im seeing the below Error.. There was no Input Exception thrown by the testcode:'TypeError: sap.ui.test.matchers.Properties is not a constructor TypeError: sap.ui.test.matchers.Properties is not a constructor at f.success (https://webidetesting4022059-w3446edba.dispatcher.int.sap.hana.ondemand.com/webapp/test/integration/pages/Translation.js?eval:240:10) at f.r.success (https://webidetesting4022059-w3446edba.dispatcher.int.sap.hana.ondemand.com/resources/sap/ui/test/Opa5.js?eval:6:2978)

Can you please help me to fix this error. Thank you in advance.

1

1 Answers

0
votes

You need to define the paths in the sap.ui.require in order to load the JS files. Please read here for a example.

sap.ui.require([
"sap/ui/test/opaQUnit",
"sap/ui/test/actions/Press",
"sap/ui/test/matchers/Properties",
"sap/ui/test/matchers/Ancestor"
],  function (opaTest, Press, Properties, Ancestor) {
     //Your code here
});

Another thing is that your should provide the correct value for key of the Item.

matchers: [ new sap.ui.test.matchers.Ancestor(oSelect), new sap.ui.test.matchers.Properties({ key: "Link"}) ],

I have tried and it should solve your problem.