For uploading files we have to go through 2 simple steps:
- type the path of a local file into an input field of type='file'
- press the button for upload/submit
Both steps are simple and realizable with well known commands. It would look like this:
 |
If you heard something about permission problems accessing input fields of type='file', this is not true for Molybdenum.
Molybdenum is working embedded in the browser and always allowed to access input fields of type='file'.
Compared with selenium-rc Molybdenum is always in *chrome mode. |
But there is another challenge. The file path to be typed in is dependent on the operating system Molybdenum is running on. Additionally, we would like to make our testsuite portable, so the file should be located relative to the testsuite.
This challenge is mastered by the command storeResourcePath (url, varname).
This command is getting an url, absolute or relative to the testsuite, and a variable name.
The command will download the resource with the given url to temporary place in the local filesystem. After that it will pass the os dependent path of this resource to the variable named by the second parameter.
This variable then can be used in the type command.
The complete command sequence will look like this: