1

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 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.