I am currently doing automation testing with an app on a browser using Robot Framework. Uploading 1 file at a time is easy using Choose File keyword. But how do you upload multiple files? In my case, I need to select all the files in that directory and upload them.
1 Answer
For me this Python custom keyword did the job with file paths separated with \n (it at least proved to work in Chrome):
from robot.libraries.BuiltIn import BuiltIn
class CustomKeywords:
def choose_files(self, locator, file_paths):
sl = BuiltIn().get_library_instance('SeleniumLibrary')
sl.find_element(locator).send_keys(file_paths)
The keyword can then be used like:
Choose Files | my_upload_field_locator | ${CURDIR}/file_1.csv \n ${CURDIR}/file_2.csv
With some additional Python this could be improved to not require \n for the file paths.