I'm looking to upload a file using Protractor testing.
Ideal scenario:
- On the form, first the user should click the 'Upload File' button
- Next a window appears where they search for their file
- And finally, the file is chosen.
createJobTest.js
it('should click upload file button', function() {
createJobPage.step5UploadFile.click().then(function(){
browser.waitForAngular();
});
});
})
var path = require('path');
it('should upload a file', function() {
var fileToUpload = '../desktop/test.txt',
absolutePath = path.resolve(__dirname, fileToUpload);
$('input[type="file"]').sendKeys(absolutePath);
$('#uploadButton').click();
});
createJobPage.js
this.step5UploadFile = element(by.id('step5--upload-file'));
createJob.html
<span class="btn btn-blue-one btn-upload" id="step5--upload-file" flow-btn translate="uploadfile"></span>
The upload file window opens but I'm getting this error:
Failed: No element found using locator: By(css selector, input[type="file"])
Any help much appreciated!