Skip to content

Latest commit

 

History

History

upload-files

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Select Files To Upload

Test Code: index.js

Tested Page: index.html

TestCafe cannot access the browser's Choose File dialog to emulate file selection. This example shows how to add files to a type="file" input without browser dialogs.

The sample page includes a <form> that contains:

  • an <input> with type="file" that stores the selected files
  • an <input> with type="submit" that sends the files to the server

During the test the t.setFilesToUpload method specifies the file paths for the <input type="file"> element. The test clicks the <input type="submit"> to initiate the file upload. Then the test receives a list of uploaded files from the server and checks it with the t.expect.eql Method.

TestCafe API Used in This Example

  1. Test Structure:
  2. Element Identification and Actions:
  3. Assertion and Evaluation: