<div class="form-fill-file">
    <input data-val="true" data-val-requiredif="Please upload invoice file." id="Upload_File" name="Upload.File" 
    type="file" value="" class="valid" aria-invalid="false">

I have written the following script:

it('Upload file', () => {
        const filepath = 'air1.pdf'


enter image description here

After I add the file, file name is displayed as shown in the image, but I am not able to assert this. I am getting the following error:

enter image description here

  • 2
    Note: Checking for this UI element doesn't say anything about the uploading of the file. You would have to validate the uploading on the service that receives the file. May 30, 2022 at 17:09

1 Answer 1


Please note that this does not check that the file is uploaded; merely that the file has been inserted in the field (put differently, you're not testing your app as much as your browser).

A better way would be to actually upload the document (add it to the field and click the Upload button or whatever it is that triggers your upload), then verify information that your application displays after the upload, or by re-downloading the file if your application lets you do that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.