我有importOBJ.JS这是我的目标文件,还有importObjSpec.js我的规范文件。当我在测试用例下面的场景中使用此文件上传文件时。我得到的错误元素是不可交互的,缺少的是我,我无法弄清楚。
importObj.js
var importBtnId = 'import-bulk-upload';
this.uploadBulkImportFile = function (filePath) {
var path = require('path');
var absolutePath = path.resolve(__dirname, filePath);
element(by.id(fileInputId)).sendKeys(absolutePath);
};
importObjSpec.js
var SImport = require('../../../../importObj.js');
it('should attempt to upload a file with various few errors', function () {
SImport.uploadBulkImportFile
('ImportInvalid.xlsx');
});
答案 0 :(得分:1)
You can try this:
const path = require('path');
const fileToUpload = '../image/dummy.txt'; // image folder is present in app folder of angular project
const absolutePath = path.resolve(__dirname, fileToUpload);
const fileElem = element(by.css('input[type="file"]'));
fileElem.sendKeys(absolutePath);