How to Perform the File Upload Operation with Protractor?

Many web applications require testing of file upload scenarios, such as uploading a profile picture, resume or any other file with various extensions.

Please refer this Protractor blog to get an idea of how to run a normal protractor test.

The following example will help you understand how to perform these scenarios with Protractor.

In order to perform the test, you need to create a new folder ‘TestUpload’, as shown below.

How to Perform the File Upload Operation with Protractor?Here, ‘abc’ is the text file to upload, ‘test_conf’ is the file with required configuration to run the test, and ‘test_spec’ is the file that includes the code to perform the file upload operation.

Steps to Run the Test

Run selenium server using the command webdriver-manager start from the command line, as shown below.

Write the following code in the ‘test_spec’ file.

Write the following code in the ‘test_conf’ file.

Open command prompt to go to the ‘TestUpload’ folder and run the following command: protractor test_conf.js

Once you run the test, you can see the uploaded file as shown below.

SHARE THIS

Get A Free Quote

One thought on “How to Perform the File Upload Operation with Protractor?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.