Upload Multiple Files

Hi All

For my test-case I need to upload two files at a time.
upload file syntax is uploading only one file at a time.
Please advise

Does it work if you just call the uploadFile() method twice? Can you zip your files and upload once?

It would be nice to see an example of what you’re working with.

Try :

WebUI.uploadFile(findTestObject('input_browse'), '\"File1\" \"File2\" ')

When you upload multiple files at once, they are registered as “file1” “file2”, so this might work.

Thank you Brandon for reply
Here I am not supposed to call uploadFile() method twice.
i.e I have to select them together while uploading


please find image attached

Thanks,
Vinay

Hi Nilau
Here is the way I used and got
Error Message
Caused by: org.openqa.selenium.InvalidArgumentException: invalid argument: File not found :slight_smile:
Syntax used
WebUI.uploadFile(findTestObject(‘FileUpload/input’), '“C:\\Users\\vnimmaga\\Documents\\ESM Documents\\NK38-FEX-03650-4506-05.dxf” “C:\\Users\\vnimmaga\\Documents\\ESM Documents\\NK38-FEX-03650-4506-05.pdf” ')

It says invalid argument because you’re saying string string with no comma between them. However, the WebUI.uploadFile API requires a TestObject followed by a single String – trying to pass two strings is not going to work (if the documentation is correct)

Is there any way that I can pass two files at a time
like attached snapshot

There’s no way to do this natively, either using Katalon or Selenium. However, it looks like there are a couple of workarounds. Does the element that takes the files happen to look something like?:

<input type="file" multiple>

Can you share the HTML for the field which takes your file upload?

Thank you Brandon for reply
here is html

I don’t see it. You can just take a screenshot from your inspector. That’s usually the easiest.

Thank you again for reply
Screenshot attachedupl
Please advise

Perfect, thank you.

Try this solution:

String path1 = "path/to/first/file";
String path2 = "path/to/second/file";
String finalPath = path1 + "\n" + path2;
WebUI.uploadFile(findTestObject("path/to/my/object"), finalPath);

You will need to replace two file paths, as well as the path to your test object, with your actual locations. If this doesn’t work, we’ll do the same thing, but replace the WebUI method call with a Selenium approach.

2 Likes

Hey Brandon
Thank you very much for advise
it worked

Good to hear, please consider marking the post that best solved your problem as a Solution, so that others that read this topic can find answers quickly. :slight_smile:

1 Like

That sir, is sneaky. I love it.

Remarkable too since it clearly avoids using the files attribute (tricky but can be done in JavaScript).

Kudos.

1 Like

Wish I could take credit. Solution was from here:

That’s pretty much what I tried to explain earlier but it was poorly worded :

Right, but the syntax was wrong. The key to the solution is the new line character though. You were on the same page!

1 Like

So 2 paths between quotations seperated with a space doesn’t work, good to know it needs a new line.
Thanks.