Answer the question
In order to leave comments, you need to log in
How to write an integration test (protractor) for multi-uploading files in Chrome?
Hello everyone
I am solving the problem of testing a multi-file upload form in a browser
For multi-upload, the angular-file-upload module is used ( https://github.com/nervgh/angular-file-upload )
The form needs to be tested in two browsers in IE 11 version and Chrome
Yes the condition that during multi-upload the number of simultaneously downloaded files should not be more than 5
Ok, for testing I use Protractor (e2e test framework based on WebDriverJS)
Here is the test code itself
it('A user attaches fileы with correct existantion', function () {
var validFile = '../test/filesToUpload/testxlsx.xlsx',
validFile2 = '../test/filesToUpload/testxls.xls',
var absolutePath = path.resolve(__dirname, validFile);
var absolutePath2 = path.resolve(__dirname, validFile2);
$('#ifile').sendKeys('"' +absolutePath2 + '" "' +absolutePath +'"');
var absolutePath = path.resolve(__dirname, invalidFile);
var errorMessageElement = $('.contactForm__errorMessage');
expect(errorMessageElement.getText()).toEqual('');
});
Answer the question
In order to leave comments, you need to log in
The option is purely on the ball, but did you try to slash in the other direction or escape in the paths?
In the wilds of the Internet, I found a solution
for Chrome files should be separated '\n'
But unlike IE, file names should not be wrapped in quotes
if (browser.browserName === 'chrome') {
resultPath = absolutePaths.join('\n');
}
if (browser.browserName === 'internet explorer') {
var newAbsolutePaths = [];
absolutePaths.forEach(function (path) {
newAbsolutePaths.push('"' + path + '"');
});
resultPath = newAbsolutePaths.join(' ');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question