Recommand · June 28, 2021 0

SAPUI5 select a file in FileUploader is not working in OPA5 test

I want to trigger a file selection in my OPA5 test. But the
following code is not working. What is the problem?

iUploadAFile: function (oText) {
          return this.waitFor({
            controlType: "sap.ui.unified.FileUploader",
            id: /ulFileUploader/,
            success: function (oFileUploader) {
              var mParameters = {
                Files: 
                {
                  "0": {
                    "name": "test.json",
                    "type": "application/json",
                    "size": 2,
                    "lastModified": 1623673777416,
                    "webkitRelativePath": ""
                  },
                  "length": 1
                },

              };
              oFileUploader[0].setValue(oText);
              oFileUploader[0].fireChange(mParameters);
              oFileUploader[0].fireUploadComplete();
            },
            errorMessage: "FileUploader not found"
          });
        },

While debugging sap.ui.getCore().byId("ulFileUploader").oFileUpload.files returns:

FileList {length: 0}
length: 0
__proto__: FileList

but should return something like:

FileList {0: File, length: 1}
0: File
lastModified: 1623673777416
lastModifiedDate: Fri Jun 18 2021 11:48:44 GMT+0200 (Mitteleuropäische Sommerzeit) {}
name: "test.json"
size: 2
type: "application/json"
webkitRelativePath: ""
__proto__: File
length: 1
__proto__: FileList

Can someone give me a hint?