I’m struggling with an issue and maybe you will be able to help me. i searched first if there was a similar topic, there were some but not really helpful for my case.
I’m trying to upload multiple files at once with Robotframework and Firefox but i’m facing an error that i don’t understand until now:
I’m using this:
Choose File locator ${file_paths}
where ${file_paths}=/Users/xxx/file1.jpg \n /Users/xxx/file2.jpg
This is working on Chrome but not on Firefox.
If anyone can help me, i would appreciate. Thank you
hello Charlie,
I did not test this because i think that by doing a loop the files will be uploaded one by one and it is not the case i would like to test.
But it doesn’t hurt to check .
With this “knowledge” - its up to the browser to decide what it would do with the “keys pressed by the user”. And if you send press following characters:
/Users/xxx/file1.jpg \n /Users/xxx/file2.jpg
its up to the browser to decide how it will interpret that.
It might very well be that
Firefox expects the filenames to be written without spaces. Your input string will send one space after the initial filename and one space before the second. Chrome might be doing handle this and maybe firefox dont ?
Maybe firefox does not support this ? Have you tried to attach 2 files manually and see how the files are sent ? And this is what @CharlieScene mentioned too. If this is the case, I’d start looking for possible workaround with javascript or reformat your input string.
Also worth mentioning is that behaviour of how file sends happen depends on the actual SUT but giving more information without knowing how its implemented, hard to say.
I’m starting to think like Charlie that Firefox does not support the multiple files upload.
I’m working in Q&A, i don’t know how to develop something in javascript to help doing this action.
I will try other separators but if nothing works i will just upload files one by one
After tryring to escape etc… this works on Firefox (replace forward slashes by : ${/} ).
I assume it doesn’t manage the slashes as in Chrome:
VAR ${files} C:${/}Users${/}Downloads${/}myfile1.txt\nC:${/}Users${/}Downloads${/}myfile2.txt
Choose File //input[@type='file'] ${files}
And by the way this works also if you need to pass a list:
VAR @{files} C:${/}Users${/}Downloads${/}myfile1.txt C:${/}Users${/}Downloads${/}myfile1.txt
FOR ${file} IN @{files}
Choose File //input[@type='file'] ${file}
END
Yeah, thats why using ${/} wont do any difference as macos uses /, ${/} on windows will correctly turn into \. What @CharlieScene actual code has a difference is that fact that
a) If using a list or b) not having space bar before and after that \n is what fixed the issue which i tried to convey with
Your input string will send one space after the initial filename and one space before the second.