How to upload file in angularjs e2e protractor testing

This is how I do it: var path = require(‘path’); it(‘should upload a file’, function() { var fileToUpload = ‘../some/path/foo.txt’, absolutePath = path.resolve(__dirname, fileToUpload); element(by.css(‘input[type=”file”]’)).sendKeys(absolutePath); element(by.id(‘uploadButton’)).click(); }); Use the path module to resolve the full path of the file that you want to upload. Set the path to the input type=”file” element. Click on the … Read more

WebDriver click() vs JavaScript click()

Contrarily to what the currently accepted answer suggests, there’s nothing specific to PhantomJS when it comes to the difference between having WebDriver do a click and doing it in JavaScript. The Difference The essential difference between the two methods is common to all browsers and can be explained pretty simply: WebDriver: When WebDriver does the … Read more