user2644620
user2644620

Reputation: 199

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

Upvotes: 0

Views: 1289

Answers (1)

Denis Duev
Denis Duev

Reputation: 611

If you don't really want to upload a real file, you can pass parameters to the fireChange function. You can use action:

 actions: function (oFileUploader) {
                            var mParameters = {
                                files: {
                                    "0": {
                                        "name": "something",
                                        "type": "application/gzip",
                                        "size": 123,
                                        "lastModifiedDate": "2013-08-14T09:42:09.000Z",
                                        "webkitRelativePath": ""
                                    },
                                    "length": 1
                                },
                                newValue: "\"newValueOfTheFile.tgz\" "
                            };

                            oFileUploader.fireChange(mParameters);
                        }

Then you can use fireUploadComplete function (to tell that upload is finished) in the same action, or in another (if you want to check something while "uploading" the file.

Upvotes: 1

Related Questions