When there is a need to upload files to your Test Application, we can upload the file from three sources:
- Local file system - In Hybrid Executions, the files needed during the Test can be uploaded from the local Test Machine
- public URLs - direct link for files from Amazon S3, imgur, shutterstock, Google Drive, Drop box e.t.c
- Testsigma Cloud Storage - Testsigma provides cloud storage option for storing your files that are needed during Test Execution.
NOTE: The only thing that you need to be careful about is that Local file system or file path can't be used in any cloud Execution Models like Testsigma Labs, Sauce Labs or BrowserStack. Reason is simple - Cloud machines doesn't have access to your local File system. And that is one of the reasons why we implemented, Testsigma Cloud Storage
We are already familiar with local files and public URLs. Let us discuss Testsigma Cloud Storage below:
Testsigma Cloud Storage
Testsigma Cloud Storage URLs are of the form:
Note: If there are large number of files or the size of files is quite big(greater than 10 MB), we would request you to host the files on a 3rd party solution or your own servers.
Getting the file URL
Getting the file path for local storage is straightforward.
For Windows machines, the path starts with the partition letter(C,D,E e.t.c) and for linux-based or mac machines, the path starts with a '/'.
Windows file URL - C:\\Users\user\My Documents\adventure-beach-compass-691637-resized.jpg
Linux or Mac - /home/user/Documents/adventure-beach-compass-691637-resized.jpg
You can get the direct link for the file from your respective Storage provider.
We need to upload the file first and then get the file URL for Testsigma Cloud Storage.
First of all, navigate to Uploads page by going through:
Select Project > Click on Test Development in Navigation Pane > Select Application > Select Version > Click on Uploads in left Context Pane
1. Go to Uploads page and click on Upload button. Enter a file name and select the file type as 'Attachments'.
2. Click on Choose File button and select the file from the local file system.
3. Click on the Upload button to upload the file. Once the upload is complete, we will be taken back to the Uploads page and we will be able to see the 'In Progress/Completed' status for the file we just uploaded.
Note: Manually refreshing the page or clicking on the cancel button while the file is in upload will cause upload failure and show the status as 'In Progress'
4. If the status is shown as 'In Progress', you may now click on refresh link right next to the Status. The status should now change to 'Completed' if the upload is complete.
5. Copy the File path as marked in the above image. This is the File path that we need to use in the NLP statement.
Example usage: Upload file testsigma-storage:/testsigma.com/uploads/9/7/adventure-beach-compass-691637-resized.jpg using the element UI Identifier
Using the URL in NLP statement
Now let us discuss how we can use these links can be used in Testsigma in the NLP statement - Upload file testdata using the element ui identifier
1. First of all, open the Create Test Step wizard, enter 'upload' in Action Text box and select the above grammar from the suggested NLP statements list.
2. Replace testdata part with the file path obtained in previous Section.
After replacing the test data and ui identifier part with actual values, it will look somewhat like:
Testsigma Cloud Storage - Upload file testsigma-storage:/testsigma.com/uploads/9/7/adventure-beach-compass-691637-resized.jpg using the element upload_button 3rd party Storage - Upload file https://s3.amazonaws.com/dev.testsigma.com/samples/videos1.mp4 using the element upload_button Local windows file - Upload file C:\\Users\user\My Documents\adventure-beach-compass-691637-resized.jpg using the element upload_button Local Linux/Mac file - Upload file /home/user/Documents/adventure-beach-compass-691637-resized.jpg using the element upload_button
3. Replace the ui identifier part with the UI Identifier for the Input box in the Webpage. Below given is an example for the Input box and Submit button:
Note: In some of the modern Web pages, the file upload button(Submit or Upload button) that we need to automate might be hidden and the file gets uploaded automatically as soon as we select the file. In cases where the Upload button element is hidden from UI, you can skip step 4.
Also, in such cases, Testsigma Chrome UI Recorder will not work and we will have to find the UI Identifier for that Input element manually - Inspect the UI Identifier manually
4. If there's a Submit or Upload button, add a Test Step to click on the button to upload the file - Click Upload button
Note: Based on the file size, you may need to add an additional "Wait" step before performing next step.
5. Continue adding further steps to the Test Case.
That's all we need perform in order to add a Test Step to upload a file using Testsigma.