# Uploading a File

**URL:** <https://forum.katalon.com/t/uploading-a-file/9932>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [March 26, 2018, 6:00pm UTC](https://forum.katalon.com/t/uploading-a-file/9932 "2018-03-26T18:00:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ilya\_Novak](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/ilya_novak/32/16103_2.png) [@Ilya\_Novak](https://forum.katalon.com/u/Ilya_Novak)\
**Post date:** [March 26, 2018, 6:00pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/1 "2018-03-26T18:00:31Z")

</div>

Hello,  
I am attempting to following the directions at [this](https://www.katalon.com/resources-center/tutorials/handle-file-uploads/ "Link: https://www.katalon.com/resources-center/tutorials/handle-file-uploads/") website to upload a file, but am not having success. Any help is appreciated…  
An object on my website has type = “file” as the website specifies:

```auto
<input id="ABC" class"foggy w250px" name="ABC" type="file">

```

When I click run Katalon generates an alert popup error message with an exclamation mark but with not text. I click OK and the script runs.

If I attempt the following…

```auto
WebUI.uploadFile(findTestObject('Upload File'), 'C:\\etc\\filename.xml')

```

… then I get the following error message…

> Test object with id ‘Object Repository/Upload File’ does not exist
> 
> Finding Test Object with id ‘Object Repository/Upload File’
> 
> Test object with id ‘Object Repository/’ does not exist
> 
> Finding Test Object with id ‘Object Repository/’
> 
> Checking object
> 
> Unable to upload file ‘C:\etc\filename.xml’ to object (Root cause: java.lang.IllegalArgumentException: Object is null)

---

<div class="post-metadata">

**Author:** ![Marek\_Melocik](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/marek_melocik/32/371_2.png) [@Marek\_Melocik](https://forum.katalon.com/u/Marek_Melocik)\
**Post date:** [March 27, 2018, 1:09pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/2 "2018-03-27T13:09:44Z")

</div>

Make sure that your local file exists in this location - _C:\etc\filename.xml_

---

<div class="post-metadata">

**Author:** ![Ilya\_Novak](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/ilya_novak/32/16103_2.png) [@Ilya\_Novak](https://forum.katalon.com/u/Ilya_Novak)\
**Post date:** [March 27, 2018, 9:01pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/3 "2018-03-27T21:01:52Z")

</div>

> Marek Melocik said:
> 
> Make sure that your local file exists in this location - _C:\etc\filename.xml_

Thanks.  
I confirmed that it exists.  
I also tried the following:

```auto
WebUI.sendKeys(findTestObject('Upload File'), 'C:\etc\filename.xml')

```

> It gives me…
> 
> Start action : sendKeys
> 
> Test object with id ‘Object Repository/Upload File’ does not exist
> 
> Finding Test Object with id ‘Object Repository/Upload File’
> 
> Finding Test Object with id ‘Object Repository/’
> 
> Sending keys ‘_C:\etc\filename.xml_’ to object: ‘tempBody’
> 
> Checking timeout
> 
> Test object with id ‘Object Repository/’ does not exist
> 
> Finding web element with id: ‘tempBody’ located by ‘By.cssSelector: body’ in ‘30’ second(s)
> 
> Found 1 web elements with id: ‘tempBody’ located by ‘By.cssSelector: body’ in ‘30’ second(s)
> 
> Keys ‘_C:\etc\filename.xml_’ sent to object: ‘tempBody’
> 
> End action : sendKeys
> 
> Test Cases/Imported from Selenium IDE Scripts/SGN
> 
> End Test Case : Test Cases/Imported from Selenium IDE Scripts/SGN
> 
> But nothing is selected

---

<div class="post-metadata">

**Author:** ![Marek\_Melocik](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/marek_melocik/32/371_2.png) [@Marek\_Melocik](https://forum.katalon.com/u/Marek_Melocik)\
**Post date:** [March 28, 2018, 6:37am UTC](https://forum.katalon.com/t/uploading-a-file/9932/4 "2018-03-28T06:37:39Z")

</div>

Hello,

I noticed this error in your log:

```auto
Test object with id 'Object Repository/Upload File' does not exist

```

Make sure that your path to test object is correct and if object exists.

Also, you are looking for some blank object in your script:

```auto
Test object with id 'Object Repository/' does not exist

```

---

<div class="post-metadata">

**Author:** ![mahesh\_joshi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mahesh_joshi/32/23869_2.png) [@mahesh\_joshi](https://forum.katalon.com/u/mahesh_joshi)\
**Post date:** [March 28, 2018, 6:40pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/5 "2018-03-28T18:40:53Z")

</div>

Use auto it for uploading a file

---

<div class="post-metadata">

**Author:** ![mahesh\_joshi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mahesh_joshi/32/23869_2.png) [@mahesh\_joshi](https://forum.katalon.com/u/mahesh_joshi)\
**Post date:** [March 28, 2018, 6:48pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/6 "2018-03-28T18:48:18Z")

</div>

What browser are you using? I had lot if issues when I was using IE for upload file finally found solution use auto it with katalon for upload file.

---

<div class="post-metadata">

**Author:** ![Ilya\_Novak](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/ilya_novak/32/16103_2.png) [@Ilya\_Novak](https://forum.katalon.com/u/Ilya_Novak)\
**Post date:** [March 28, 2018, 10:09pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/7 "2018-03-28T22:09:58Z")

</div>

[mahesh joshi](https://forum.katalon.com/profile/3877/mahesh%20joshi "Link: /profile/3877/mahesh%20joshi") said:

> Use auto it for uploading a file

What do you mean?

---

<div class="post-metadata">

**Author:** ![mahesh\_joshi](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/mahesh_joshi/32/23869_2.png) [@mahesh\_joshi](https://forum.katalon.com/u/mahesh_joshi)\
**Post date:** [March 28, 2018, 11:02pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/8 "2018-03-28T23:02:56Z")

</div>

This will help see the video [https://www.youtube.com/watch?v=OvrYrbNHDcw](https://www.youtube.com/watch?v=OvrYrbNHDcw)

---

<div class="post-metadata">

**Author:** ![kishor\_sharma](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kishor_sharma/32/16104_2.png) [@kishor\_sharma](https://forum.katalon.com/u/kishor_sharma)\
**Post date:** [March 28, 2018, 11:41pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/9 "2018-03-28T23:41:26Z")

</div>

> Ilya Novak said:
> 
> Hello,  
> I am attempting to following the directions at [this](https://www.katalon.com/resources-center/tutorials/handle-file-uploads/ "Link: https://www.katalon.com/resources-center/tutorials/handle-file-uploads/") website to upload a file, but am not having success. Any help is appreciated…  
> An object on my website has type = “file” as the website specifies:
> 
> ```auto
> <input id="ABC" class"foggy w250px" name="ABC" type="file">
> 
> ```
> 
> When I click run Katalon generates an alert popup error message with an exclamation mark but with not text. I click OK and the script runs.
> 
> If I attempt the following…
> 
> ```auto
> WebUI.uploadFile(findTestObject('Upload File'), 'C:\\etc\\filename.xml')
> 
> ```
> 
> … then I get the following error message…
> 
> > Test object with id ‘Object Repository/Upload File’ does not exist
> > 
> > Finding Test Object with id ‘Object Repository/Upload File’
> > 
> > Test object with id ‘Object Repository/’ does not exist
> > 
> > Finding Test Object with id ‘Object Repository/’
> > 
> > Checking object
> > 
> > Unable to upload file ‘C:\etc\filename.xml’ to object (Root cause: java.lang.IllegalArgumentException: Object is null)

you can use the following keyword to upload a file:

for more details: [https://www.katalon.com/resources-center/tutorials/handle-file-uploads/](https://www.katalon.com/resources-center/tutorials/handle-file-uploads/)

```auto
WebUI.uploadFile(findTestObject('Upload File'), 'C:\\\\Users\\\\Public\\\\Pictures\\\\Sample Pictures\\\\Desert.jpg') 

```

---

<div class="post-metadata">

**Author:** ![veera\_palla](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/veera_palla/32/23870_2.png) [@veera\_palla](https://forum.katalon.com/u/veera_palla)\
**Post date:** [March 29, 2018, 12:35am UTC](https://forum.katalon.com/t/uploading-a-file/9932/10 "2018-03-29T00:35:22Z")

</div>

> [mahesh joshi](https://forum.katalon.com/profile/3877/mahesh%20joshi) said:
> 
> This will help see the video [https://www.youtube.com/watch?v=OvrYrbNHDcw](https://www.youtube.com/watch?v=OvrYrbNHDcw)

Similar way we can execute .vbs files also.

---

<div class="post-metadata">

**Author:** ![madhawa](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@madhawa](https://forum.katalon.com/u/madhawa)\
**Post date:** [February 7, 2019, 8:51am UTC](https://forum.katalon.com/t/uploading-a-file/9932/11 "2019-02-07T08:51:30Z")

</div>

try this [https://stackoverflow.com/questions/45398100/how-to-upload-a-file-photo-using-katalon-studio](https://stackoverflow.com/questions/45398100/how-to-upload-a-file-photo-using-katalon-studio)

---

<div class="post-metadata">

**Author:** ![SIVHD](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/sivhd/32/4955_2.png) [@SIVHD](https://forum.katalon.com/u/SIVHD)\
**Post date:** [May 18, 2019, 8:30pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/12 "2019-05-18T20:30:05Z")

</div>

Try new katalon plugin 😃 with robo uploading work so great

> **[UploadFile Keywords](https://store.katalon.com/product/69/UploadFile-Keywords)**
>
> Katalon Store is a collaborative marketplace that allows users to develop and share plugins, integrations, and keywords that enhance Katalon Studio capabilities.

> Blockquote  
> import com.kms.katalon.keyword.uploadfile.UploadFile

CustomKeywords.‘com.kms.katalon.keyword.uploadfile.UploadFile.uploadFileUsingRobot’(findTestObject(‘Object Repository/Folder/Object’), ‘D:\Windows\Desktop\file.png’)

if using dynamic object :

CustomKeywords.‘com.kms.katalon.keyword.uploadfile.UploadFile.uploadFileUsingRobot’(object name), ‘D:\Windows\Desktop\file.png’)

---

<div class="post-metadata">

**Author:** ![khadapynurhuda](https://avatars.discourse-cdn.com/v4/letter/k/51bf81/32.png) [@khadapynurhuda](https://forum.katalon.com/u/khadapynurhuda)\
**Post date:** [July 3, 2019, 6:28am UTC](https://forum.katalon.com/t/uploading-a-file/9932/13 "2019-07-03T06:28:58Z")

</div>

Can you write here, step by step to do it?

---

<div class="post-metadata">

**Author:** ![andre.dada](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andre.dada](https://forum.katalon.com/u/andre.dada)\
**Post date:** [July 12, 2019, 11:44am UTC](https://forum.katalon.com/t/uploading-a-file/9932/14 "2019-07-12T11:44:42Z")

</div>

1. First, create a keyword to the file upload button or link, something like: “Object Repository/Page\_Add\_Document\_To\_Current\_Account/lnk\_choose\_a\_file”

2. Next, create a method call for which will handle the upload, like  
class uploadNewFile {  
/\*\*

3. Next, call the method where it needs to be in your code and it will appear something like:  
CustomKeywords.‘methodCalls.uploadNewFile.uploadFileToTest’(findTestObject( **null** ), ‘’)

4. Next, replace **null** in 3 above with the keyword you created in 1 above, then insert the filepath of the file to be uploaded into the ‘’ in 3 above.

**UPDATE** :  
//KS seems to have an issue with selecting the correct path to the file, so the best solution, for me, was to include the desired docs to be added into the **Data Files** container in KS, then call it from there. This ensures that the same doc is called, no matter who or where the test is being run from

WebUI.delay(2)

//this string will replace the user/system path being used to run the test at any particular time  
String textDir = RunConfiguration.getProjectDir()

//the default path connectors were failing in the tests, so, it was necessary to replace them, which worked for me  
String replaced = textDir.replace(’/’, ‘\’)  
// **\_please note that the single backslash in code above should be double, as in \ \ , but when entered into the comments here, it’s represented as a single backslash. Not sure why this is the case… \_**

1. The final statement would be something like:  
CustomKeywords.‘methodCalls.uploadNewFile.uploadFileToTest’(findTestObject(‘Object Repository/Page\_Add\_Document\_To\_Current\_Account/lnk\_choose\_a\_file’),  
replaced + ‘\Data Files\name-of-file.txt/png/doc/etc’)  
// **\_please note that the single backslash before and after Data Files, and for all paths to the file to be uploaded, should be double, as in \ \ , but when entered into the comments here, it’s represented as a single backslash. Not sure why this is the case… \_**  
All the best

---

<div class="post-metadata">

**Author:** ![khadapynurhuda](https://avatars.discourse-cdn.com/v4/letter/k/51bf81/32.png) [@khadapynurhuda](https://forum.katalon.com/u/khadapynurhuda)\
**Post date:** [July 29, 2019, 8:22am UTC](https://forum.katalon.com/t/uploading-a-file/9932/15 "2019-07-29T08:22:38Z")

</div>

Well, thank you, Sir.

---

<div class="post-metadata">

**Author:** ![paresh.soni](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/paresh.soni/32/16103_2.png) [@paresh.soni](https://forum.katalon.com/u/paresh.soni)\
**Post date:** [August 2, 2019, 7:38pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/16 "2019-08-02T19:38:21Z")

</div>

Even I am having similar problem. Am not able to upload the file even thought it clicks on an object but doesn’t enter the path not uploading document.

---

<div class="post-metadata">

**Author:** ![paresh.soni](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/paresh.soni/32/16103_2.png) [@paresh.soni](https://forum.katalon.com/u/paresh.soni)\
**Post date:** [August 2, 2019, 7:58pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/17 "2019-08-02T19:58:16Z")

</div>

I tried also this way but it doesn’t like file name after filepath and where filename starts and my file name is blankpage.pdf.  
CustomKeywords.‘methodCalls.uploadNewFile.uploadFileToTest’(findTestObject(‘objectname’), ‘D:/Sample Document/blankpage.pdf’)  
expecting ‘)’, found ‘blankpage’ @ line 55, column 111

---

<div class="post-metadata">

**Author:** ![andre.dada](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andre.dada](https://forum.katalon.com/u/andre.dada)\
**Post date:** [August 5, 2019, 10:54am UTC](https://forum.katalon.com/t/uploading-a-file/9932/18 "2019-08-05T10:54:55Z")

</div>

Hi all,

I’ve amended my test to include a better option of navigating to the desired file to be uploaded.

Regards,  
A

---

<div class="post-metadata">

**Author:** ![paresh.soni](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/paresh.soni/32/16103_2.png) [@paresh.soni](https://forum.katalon.com/u/paresh.soni)\
**Post date:** [August 9, 2019, 8:15pm UTC](https://forum.katalon.com/t/uploading-a-file/9932/19 "2019-08-09T20:15:23Z")

</div>

> [@andre.dada](#):
>
> //KS seems to have an issue with selecting the correct path to the file, so the best solution, for me, was to include the desired docs to be added into the **Data Files** container in KS, then call it from there. This ensures that the same doc is called, no matter who or where the test is being run from

I didn’t get this part of you update.  
//KS seems to have an issue with selecting the correct path to the file, so the best solution, for me, was to include the desired docs to be added into the **Data Files** container in KS, then call it from there. This ensures that the same doc is called, no matter who or where the test is being run from.  
Please provide in detail how to add desired docs into the **Data Files** as I can only add excel or csv filed in Data Files.

---

<div class="post-metadata">

**Author:** ![andre.dada](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andre.dada](https://forum.katalon.com/u/andre.dada)\
**Post date:** [August 12, 2019, 9:20am UTC](https://forum.katalon.com/t/uploading-a-file/9932/20 "2019-08-12T09:20:36Z")

</div>

@paresh.soni, simply right-click on the desired folder in **Data Files** and select the option to _ **Open containing folder.** _

Add the required file here and when you follow the steps I outlined above, you should be able to reach the file and upload it

[Next page](https://forum.katalon.com/t/uploading-a-file/9932.md?page=2)
