How to Upload a file from file from explorer

Hello, How is everyone?
yes I read a couple documents in the community about this and still not understanding how to do it. The articles are also out dates, so I wanted to see if there is anything else I can do.

How do I upload a form from file explorer ( could be headless if needed also)

When I click this button the “ADD Policy” button below

The file explorer window appears

I want the code to “enter the file path of the file in file explorer”: URL which is c: drive

or can I add it to desktop? which ever is easier.

File type: PDF

I need to double click it in order for it to be added to the website.

It will be added here once I click it in file explorer

When I use the web recorder of course it does not interact with my local PC.

Also its NOT an INPUT BOX so I cant write a code like this WebUI.uploadFile(findTestObject(‘input_browse’), ‘D:\test-photo.png’)…

Do I need to download any other tool to get this to happen.

1 Like

The below link might assist you.

Edit: Does your pathway have double slashes in it? It needs them. (A single slash is an escape character, like for the “new line”, \n, or “tab”, \t, so the second slash says that the first slash is just a slash.)

gImportFileName = 'G:\\Katalon Test Cases\\KatalonCASE\\Data Files\\Details.txt';

Could you doublecheck that there isnt an input field? Search for //input in dev tools maybe? I’ve tested a page where the input field was not that close to the button in the DOM

-------------If I add a doc manually


I think you can use the Katalon keyword in this case - it requires an input of type = file, which is what you have shown above. There are alternatives but this is the out-of-box solution:

WebUI.uploadFile(findTestObject(‘input_browse’), ‘D:\\test-photo.png’)

Create a test object for the input eg


then update the filepath as required (remembering the double slashes).

The keyword doc is suitable for this case I think (there are several alternatives on the forum as well):

Hi @naomy.arnold, See this post: How-to use ‘sendKeys’ or 'File Upload' to upload files

Ok I will try next week. Sorry i didnt respond sooner, I been in meetings.

Dev team is working on making it an input field. I could not get it to work.