In the mabl Trainer, you can combine file upload steps with assertions to ensure your web application is handling file upload interactions as expected. File uploads are added to your mabl workspace for future test editing and cloud runs, and you can access them by going to Configuration > File Uploads in the app.
Read on to learn more about uploading files to your web app, including:
- Training a file upload step
- Replaying file upload steps in the Trainer
- Updating file input
- Custom file upload steps
- Uploading different files for different scenarios
Keeping your data safe
Just like other data in your workspace, file uploads are encrypted using industry-standard best practices for key strength and key management. File uploads remain in the mabl cloud until you choose to delete them.
Training a file upload step
To get started, open the mabl Trainer and navigate to the page in your application where the file upload step needs to occur. Make sure the record button is on.
- Click on the "file upload" or "choose file" button in your application.
- In the file selection dialog, select the file you would like to upload from your computer.
- Click Open. The Trainer will automatically record a step that sets the file input: "Set file input to {name-of-file} .
- Record the action to submit the file upload in your application. For example, click on the "submit" button.
- Create an assertion to confirm that the upload was successful. This assertion will depend on what happens in the application after a successful file upload.
File requirements
By default, file uploads are supported up to 100 MB.
The maximum filename limit is 255 ASCII characters. However, if the filename includes non-ASCII characters the limit may be as low as 84 characters, depending on character encoding and the 255 bytes available for filenames.
Replaying file upload steps in the Trainer
After recording a file upload step, delete the click step that opens the file selection dialog. Otherwise, you will need to manually dismiss the file selection dialog every time during Trainer replay.
mabl cannot interact with the file selection dialog during Trainer replay or local/cloud runs because it is part of the operating system, not the HTML of the page. Learn more about what the mabl Trainer can and cannot interact with here.
Updating file input
To update the file input, click on the pencil icon next to the recorded file upload step. You can choose a new file input from the dropdown.
To use a new file upload that has not yet been uploaded to the mabl application, delete the existing file upload step and record a new upload step with new file input.
Custom file upload steps
If you cannot target the file input element using recorded steps, you can also create "set file input" steps using CSS or XPath. For custom file upload steps, keep in mind the following:
- The target element for the "set file input" step must be a file-type input element.
- Custom file upload steps only allow selecting an existing file from your mabl workspace.
Try Configure Find first
Before you use a CSS query or XPath expression to create a file upload step, try recording the file upload and adding Configure Find to the step to tell mabl what attributes the file-type input element should have.
Configure Find handles a lot of the same use cases as steps that use CSS or XPath while also being more maintainable, since you don't need to know CSS or XPath to troubleshoot the step if something goes wrong.
Uploading different files for different scenarios
If you need to upload a different file depending on the situation, use conditionals to evaluate the scenario and set the input to the appropriate file. The following screenshot shows test steps that upload a different file depending on the DataTable scenario:
Uploading a different file according to the DataTable scenario
Limitations
Keep in mind the following limitations for file uploads in the mabl Trainer:
- No support for drag-and-drop file selection
- No support for selecting multiple files for one file upload step