My attempt to test the image upload feature with Protractor failed, as my script did not work properly. Here is the image dialog box that I am trying to interact with. When clicking on the dialog box, it opens a window to select an image. After selecting an image, the box behaves like this image. My goal is to create a script that uploads an image and then clicks on the "Save" button. Here is the CSS of the dialog box: CSS of dialogue box. The following is the script that I attempted but unfortunately, it did not work. The encountered error message can be found here.
var path = require('path');
var fileToUpload = '../new image.jpeg';
var absolutePath = path.resolve('__dirname', fileToUpload);
console.log(absolutePath);
var fileElem=element(by.css('label[for="cropper-file-input"]'));
browser.wait(EC.presenceOf(fileElem), 2000,);
fileElem.sendKeys(absolutePath);