目前我正在使用此方法上传文件:
uploadImage: function(fileToUpload) {
//clicking the add photo button
var addMediaModal = element.all(by.css('#px-select-photo')).first();
browser.executeScript('arguments[0].click()', addMediaModal.getWebElement());
browser.actions().mouseMove(addMediaModal).click().perform();
var path = require('path');
//the file to upload
var absolutePath = path.resolve(__dirname, fileToUpload)
var elm = $('input[type="file"]');
browser.executeScript('var input = $("input:file"); input[0].removeAttribute("class");');
elm.sendKeys(absolutePath);
},

仅适用于Chrome。 Firefox和IE打开上传窗口,只是挂起,而chrome完成幕后的一切。
<span class="ui-button-text"><span class="upload-title">Add Photos</span>
<input style="cursor: pointer;" id="px-select-photo" name="file" class="me-fileUpload" data-label="AddPhotos" data-filetypes="jpg|jpeg|gif|png" data-invalidmessageresource="ErrorUnsupportedPhotoFormat"
multiple="" type="file">
</span>
&#13;