Skip to Content
avatar image
Former Member

Sapui5 opa5 How to upload a file using opa5 script

im facing an issue in Uploading a file using OPA5 Script. Can you please help me.

Please look my code..

xml::

<sap.ui.unified:FileUploader
                    id="fileUploader"
                    name="myFileUpload"
                    uploadUrl="upload/"
                    width="400px"
                    tooltip="Upload your file to the local server"
                    />

OPA Script ::

When.waitFor({
                            id: "fileUploader",
                            viewName: sViewName,
                            //actions: new Press(),
                            success : function (oFirstItem) {
                                oFirstItem.$().trigger("tap");
                                Opa5.assert.ok(true, "Upload Dialog got opened");
                            },
                            errorMessage: "Form Was not Submitted"
                        });

Can you please help me to apply right code to upload a file using OPA script.

Thank you in advance

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 07 at 03:11 PM

    Hi,

    If the item is a dialog, you should use the parameter "searchOpenDialogs: true" inside your waitFor operation, like this:

    When.waitFor({
                                id: "fileUploader",
                                viewName: sViewName,
                                //actions: new Press(),
                                searchOpenDialogs: true,
                                success : function (oFirstItem) {
                                    oFirstItem.$().trigger("tap");
                                    Opa5.assert.ok(true, "Upload Dialog got opened");
                                },
                                errorMessage: "Form Was not Submitted"
                            });
    
    

    For more information, look in the waitFor function on this page: https://openui5.hana.ondemand.com/#/api/sap.ui.test.Opa5 .

    However, I cannot tell if you have successfully clicked on the item using the oFirstItem.$().trigger("tap") statement. You could also use the integrated oFirstItem.firePress() if that did not work.

    -Alex

    Add comment
    10|10000 characters needed characters exceeded