Uploading an image file with Nightwatch.js
As someone above has mentioned, you can pass the absolute path to your input[type="file"] as if you were typing text into a field.
This uses nightwatch's setValue
function. You can retrieve the current directory path using Node's __dirname
global var.
For example:
.setValue('#upload-input', __dirname + '\\upload.jpg')
Use this for uploading image from local desktop
.setValue('input[type="file"]', require('path').resolve('/home/My-PC/Desktop/img.png'))
Use client.setValue function to set the absolute path of your image. Here is the working example in my project.
client.setValue('#editPictures .modal-body input[type="file"]', '/Users/testing/pictures/CAM00003.jpg');