I am testing a web application using protractor, and one of the tests requires me to push an image to the device so it can be used in the test case. The way I am testing this is that, first I push the image to the device and then upload the image as a local file. I am using the following code for that
const fileread = fs.readFileSync(absolutePath, {encoding: 'base64'})
console.log(await browser.driver.pushFileToDevice('//storage//emulated//0//Downloads//test.jpg', fileread));
await element(by.css('input[type="file"]')).sendKeys('//storage//emulated//0//Downloads//test.jpg');
The issue I am facing is that the image is not loaded and when I try to enlarge the image, I get a broken image icon.
I am starting chrome using the following flags
"--use-fake-device-for-media-stream",
"--use-fake-ui-for-media-stream",
"--ignore-certificate-errors",
"--allow-file-access-from-files",
"--enable-local-file-access",
"--show-android-files-in-files-app"
Can anyone help me out?