How to Handle File Uploads

In general, we need to automate scenarios like uploading a file into the application for attaching profile pictures or documents. This tutorial demonstrates handling the file upload feature and verifying downloaded files using Katalon Studio.

What is File Upload in testing?

The file upload widget is the input tag having attribute type equal to file. It allows us to upload all file formats (.jpg, .png, .txt…)

Let’s work on the case in which we need to upload a file and validate whether the file is uploaded.

Steps:

  • Launch the URL of the application
  • Maximize the window
  • Use the file upload widget to upload a file

Manual Mode:

Handle File Uploads testing Manual Mode

We can also use the script mode. Below script is the code to upload a file and validate the uploaded file.

Script Mode:

File upload using Send Keys

We can also upload files by using the Send Keys method. Send Keys works for the input tag having type equal to file.

Steps:

  • Launch the URL of the application
  • Maximize the window
  • Use the Send Keys method to upload a file.
  • Send Keys accepts file URL as string.

Manual Mode:

File Uploads using send key

Script Mode:

Verify a Downloaded File

After downloading a file from the application we need to verify whether the file is successfully downloaded and saved in a folder.

For that, we need to set preferences for Firefox, as shown in the Image below.

Verify a Downloaded file

Script Mode:

We have just learned how to handle file uploads and verify downloaded files using Katalon Studio. You can download the source code here.

For further instructions and help, please refer to Upload File guideline.

81% people found this helpful
Related testing tools
Katalon Studio
Best automation solution for software testing team. Completely free!
Katalon Recorder
Ultimate Selenium IDE to record, play, and debug app. Fast and extensible!
Katalon Analytics
Bring you to the next level of test execution reports. Smart and seamless solution!
Scroll up