Currently, I am in the process of writing a Selenium test case where one of the steps involves uploading a file through Dropzone.js.
(Given that Selenium can execute Javascript in the browser, it would be acceptable to achieve this programmatically with Javascript as well.)
I aim to circumvent the need to simulate the entire process of opening the file browser window, selecting a file, etc., as this complexity exceeds the capabilities of the web driver. Ideally, I envision a pseudo code sequence like this:
1. Identify a Dropzone element
2. Specify the file path
3. Submit (upload the file)
An alternative approach was suggested in a related query (Unable to upload file using python selenium webdriver on http://www.dropzonejs.com) which involves utilizing the "dz-hidden-input" element (a DOM file input).
Regrettably, this method does not prove effective (at least not in the current version of Dropzone) - setting the file to the element results in an empty Dropzone .files array and no successful upload.
After delving into the Dropzone source code, I devised a functional solution by extending the previous technique:
1. Set the file path in the "dz-hidden-input" element
2. Utilize javascript to retrieve the File object from the element
3. Incorporate dropzone.addFile(file) to incorporate the file
However, I have reservations about this being a workaround, as both the hidden-input and .addFile methods lack documentation, making the test susceptible to failures if Dropzone undergoes changes in implementation.
Hence, my inquiry is whether there exists a more efficient or documented procedure for achieving this task?
(For clarification - my objective is to upload a fresh file, as opposed to displaying an existing file per the information outlined in the Dropzone FAQ)